该表必须按标题,正文和页脚的顺序包含行部分 [英] The table must contain row sections in order of header, body, then footer
本文介绍了该表必须按标题,正文和页脚的顺序包含行部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用printwebhelper方法打印gridview内容
i只需将gridview传递给班级
该课程为:
I am using printwebhelper method for printing the gridview content
i just pass gridview to the class
the class is :
public static void PrintWebControl(Control ctrl, string Script, GridView SalesGridView)
{
//if (System.Web.HttpContext.Current.(string)Session["isgrid"] == "grid")
//{
// GridView grid = (GridView)ctrl;
// grid.AllowPaging = false;
// grid.DataBind();
if (SalesGridView.Rows.Count > 0)
{
//}
SalesGridView.UseAccessibleHeader = true;
SalesGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
SalesGridView.FooterRow.TableSection = TableRowSection.TableFooter;
SalesGridView.Attributes["style"] = "border-collapse:separate";
foreach (GridViewRow row in SalesGridView.Rows)
{
if (row.RowIndex % 30 == 0 && row.RowIndex != 0)
{
row.Attributes["style"] = "page-break-after:always;";
}
}
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
string style = "<style type = 'text/css'>td { padding: 4px; border: solid 1px #c1c1c1; color: #474545; font-family:Arial; font-size:12px } th { padding: 2px 2px; color: #3e4d9e; background: #e0d7f4 ; font-family:Arial; text-align:left;text-indent:10px; font-size:14px ;border-top: solid 1px #a99cec; border-left:none;border-right:none; border-bottom:none }{ width: 100%;background-color: #fff; margin: 5px 0 10px 0; border-top: solid 1px #a99cec; border-left:solid 1px #a99cec;border-right:solid 1px #a99cec;font-family:Arial; font-size:15px; </style>";
HttpContext.Current.Response.Write(style);
HttpContext.Current.Response.End();
}
}
但是当它到达时
but when it reached
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
行显示错误
表必须按标题,正文,然后页脚的顺序包含行部分
line it showing the error
The table must contain row sections in order of header, body, then footer
推荐答案
这是动态创建的页眉还是页脚?
试试这个
Is this a dynamically created header or footer?
Try this
protected void SalesGridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 0)
{
e.Row.RowType = DataControlRowType.Header;
}
}
这篇关于该表必须按标题,正文和页脚的顺序包含行部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文