Srinivas Mantha
asked on
ASP.NET 3.5: Problem exporting grid contents to word from a child page: ErrorCode=-2147467259
I am using ASP.NET 3.5 with C# code. I have gridview by name “gridinfo” in a child page populated by records from a database. I am using a standard function to export the grid contents to word.
private void exportgridinfotoword()
{
Response.Clear();
Response.AddHeader("conten t-disposit ion", "inline;filename=abc.doc") ;
Response.Charset = "";
Response.Cache.SetCacheabi lity(HttpC acheabilit y.NoCache) ;
Response.ContentType = "application/vnd.word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gridinfo.RenderControl(htw );
Response.Write(sw.ToString ());
Response.Flush();
Response.End();
}
}
I am getting the following error
Message="Control 'ctl00_Main_gridinfo' of type 'GridView' must be placed inside a form tag with runat=server." Source="System.Web"
What is the problem and likely solution
private void exportgridinfotoword()
{
Response.Clear();
Response.AddHeader("conten
Response.Charset = "";
Response.Cache.SetCacheabi
Response.ContentType = "application/vnd.word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gridinfo.RenderControl(htw
Response.Write(sw.ToString
Response.Flush();
Response.End();
}
}
I am getting the following error
Message="Control 'ctl00_Main_gridinfo' of type 'GridView' must be placed inside a form tag with runat=server." Source="System.Web"
What is the problem and likely solution
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The error message looks like you are mssing runat="server2 on your form tag ot <form sunat="server"> itself is missing
-- Deepu