为什么在行gvdetails.RenderControl(htw)中给出错误? [英] why the error is giving in the line gvdetails.RenderControl(htw);
本文介绍了为什么在行gvdetails.RenderControl(htw)中给出错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么错误将int行赋予gvdetails.RenderControl(htw);
我的CS代码在下面给出
Why error is giving int the line gvdetails.RenderControl(htw);
My cs code is given below
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvdetails.AllowPaging = false;
gvdetails.DataBind();
//Change the Header Row back to white color
gvdetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Applying stlye to gridview header cells
for (int i = 0; i < gvdetails.HeaderRow.Cells.Count; i++)
{
gvdetails.HeaderRow.Cells[i].Style.Add("background-color", "#507CD1");
}
int j = 1;
//This loop is used to apply stlye to cells based on particular row
foreach (GridViewRow gvrow in gvdetails.Rows)
{
//gvrow.BackColor = Color.White;
if (j <= gvdetails.Rows.Count)
{
if (j % 2 != 0)
{
for (int k = 0; k < gvrow.Cells.Count; k++)
{
gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
}
}
}
j++;
}
gvdetails.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
[edit]已添加代码块,将我的内容视为纯文本..."选项已禁用,代码已格式化-OriginalGriff [/edit]
[edit]Code block added, "Treat my content as plain text..." option disabled, code formatted - OriginalGriff[/edit]
推荐答案
已答应从中删除未回答的列表-问题与更多信息重复.
请不要删除-我希望OP看到他的格式化和未格式化代码之间的区别.
Answered to remove from unanswered list - question is duplicated with more information.
Please do not delete - I want the OP to see the difference between his code formatted and unformatted.
这篇关于为什么在行gvdetails.RenderControl(htw)中给出错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文