TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mohammed shamsheer
NA
394
143.6k
The table must contain row sections in order of header, body
Jan 14 2014 4:25 AM
I am using printwebhelper method for printing the gridview content
i just pass gridview to the class
the class is :
<pre lang="c#">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();
}
}
</pre>
but when it reached
<pre lang="cs">pg.DesignerInitialize();
pg.RenderControl(htmlWrite);</pre>
line it showing the error
The table must contain row sections in order of header, body, then footer
Reply
Answers (
0
)
Drop Down List control
Generate pdf with FOP issue