Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML ExportToExcel按钮_Html_Asp.net - Fatal编程技术网

HTML ExportToExcel按钮

HTML ExportToExcel按钮,html,asp.net,Html,Asp.net,我的应用程序中有一个ExportToExcel按钮,可以随时看到。我希望仅在单击“提交”并显示结果后才显示此内容。 代码如下: 受保护的void ExportToExcel(对象发送方,事件参数e) { Response.Clear(); Response.Buffer=true; Response.ContentType=“text/xls”; AddHeader(“内容处置”、“附件;文件名=HistoricalReporting.xls”); 响应。Charset=“”; 使用(Str

我的应用程序中有一个ExportToExcel按钮,可以随时看到。我希望仅在单击“提交”并显示结果后才显示此内容。
代码如下:


受保护的void ExportToExcel(对象发送方,事件参数e)
{
Response.Clear();
Response.Buffer=true;
Response.ContentType=“text/xls”;
AddHeader(“内容处置”、“附件;文件名=HistoricalReporting.xls”);
响应。Charset=“”;
使用(StringWriter sw=new StringWriter())
{
HtmlTextWriter hw=新的HtmlTextWriter(sw);
//导出所有页面的步骤
GridView1.AllowPaging=false;
这是BindGridView();
GridView1.HeaderRow.BackColor=颜色.白色;
foreach(GridView1.HeaderRow.Cells中的TableCell单元格)
{
cell.BackColor=GridView1.HeaderStyle.BackColor;
}
foreach(GridView1.Rows中的GridViewRow行)
{
row.BackColor=Color.White;
foreach(行中的表格单元格。单元格)
{
如果(row.RowIndex%2==0)
{
cell.BackColor=GridView1.AlternatingRowStyle.BackColor;
}
其他的
{
cell.BackColor=GridView1.RowStyle.BackColor;
}
cell.CssClass=“textmode”;
}
}
GridView1.渲染控制(hw);
//将数字格式化为字符串的样式
字符串样式=@“.textmode{}”;
回应。写作(风格);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
}
公共覆盖无效VerifyRenderingInServerForm(控件)
{
/*验证是否呈现控件*/
}

?看起来很直截了当。使按钮开始不可见。处理提交按钮的单击事件,并使按钮可见。你有没有尝试过,或者你只是想让我们为你写所有的代码?你可能想考虑接受你的一些其他问题,如回答一般,你会得到更多的反应,当你回答问题的答案。看起来很直截了当。使按钮开始不可见。处理提交按钮的单击事件,并使按钮可见。你有没有尝试过,或者你只是想让我们为你写所有的代码?你可能想考虑接受你的一些其他问题,如回答一般,你会得到更多的反应,当你标记问题回答。