SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error in Export to Excel

    here is my coding for Export to Excel :
    if (gvIncidentDetail.Rows.Count > 0)
    {
    Response.Clear();
    string filename = "Excel.xls";
    Response.AddHeader("content-disposition", "attachment;filename=" + filename);
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.xls";
    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    gvIncidentDetail.RenderControl(htmlWrite);
    Response.Write(stringWrite.ToString());
    Response.End();
    }

    i m getting ths error:
    Control 'ctl00_centerContentHolder_gvIncidentDetail' of type 'GridView' must be placed inside a form tag with runat=server.

    can anyone tell me wht ths error contain?

  2. #2
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's fairly self-explanatory. Your control needs to be inside a form with the runat="server" attribute.
    Code:
    <form id="Form1" runat="server">
    
    <asp:GridView ..... etc.
    
    </form>

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cringer View Post
    it's fairly self-explanatory. Your control needs to be inside a form with the runat="server" attribute.
    Code:
    <form id="Form1" runat="server">
    
    <asp:GridView ..... etc.
    
    </form>
    but i m using masterpage so there in no form tag in .aspx page

  4. #4
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there are form tag in your masterpage?

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cringer View Post
    is there are form tag in your masterpage?
    yes it is there in masterpage

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Naples, FL
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried the code in a standalone .aspx page that has a form with runat=server in? Try it without the masterpage.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •