tavo2k1
03-17-2006, 08:01 PM
I am trying to send a GridView control in the body of an e-mail, System.Net.Mail, ASP.NET 2.0. I had tried different ways of doing this. I am including the code I am using to render the control to be included in the message body.
Code:
StringBuilder SB = new StringBuilder();
StringWriter SW = new StringWriter(SB);
HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
MyGrid.RenderControl(htmlTW);
string dataGridHTML = SB.ToString();
I have put code in the Page_Int, Page_PreRender, Page_Load. But nothing happens, only in Page_Load, where it gives me a couple of errors;
Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
Or
If I want to render all controls in a page “this.form1.RenderControl(htmlTW)”. I get the following error;
RegisterForEventValidation can only be called during Render();
Code:
StringBuilder SB = new StringBuilder();
StringWriter SW = new StringWriter(SB);
HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
MyGrid.RenderControl(htmlTW);
string dataGridHTML = SB.ToString();
I have put code in the Page_Int, Page_PreRender, Page_Load. But nothing happens, only in Page_Load, where it gives me a couple of errors;
Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
Or
If I want to render all controls in a page “this.form1.RenderControl(htmlTW)”. I get the following error;
RegisterForEventValidation can only be called during Render();