469,934 Members | 2,627 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

error "Control 'GridView' must be placed inside a form tag with runat=server"

Hi,
I've an asp.net .ascx form and a gridview on that form.I've placed that form on an .aspx. Now while I'm trying to import data from gridview to excel it is showing the error "Control 'GridView' must be placed inside a form tag with runat=server"

see my code:

Expand|Select|Wrap|Line Numbers
  1.  <form action="readdata.aspx" runat="server">
  2.         <table>
  3.             <tr>
  4.                 <td style="width: 100px">
  5.                     <asp:Label ID="lblSearchBy" runat="server" Text="Search by:"></asp:Label></td>
  6.                 <td style="width: 100px">
  7.                     <asp:DropDownList ID="cmbSheets" runat="server" DataSourceID="SqlDataSource1" DataTextField="ISSUEID" DataValueField="ISSUEID">
  8.                         <asp:ListItem Value="0">Students</asp:ListItem>
  9.                         <asp:ListItem Value="1">Mathematics</asp:ListItem>
  10.                         <asp:ListItem Value="2">Geography</asp:ListItem>
  11.                     </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MCWEBConnectionString2 %>"
  12.                         SelectCommand="SELECT [ISSUEID] FROM [MCISSUES]"></asp:SqlDataSource>
  13.                 </td>
  14.  
  15.                 <td>
  16.                     <asp:Button ID="btnSearch" runat="server" Text="Search" /></td>
  17.             </tr>
  18.         </table>
  19.         <br />
  20.      <asp:GridView ID="dgResults" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
  21.             <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
  22.             <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
  23.             <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
  24.             <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
  25.             <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
  26.             <AlternatingRowStyle BackColor="White" />
  27.         </asp:GridView>
  28.         <asp:Button ID="btnToExcelByResponse" runat="server" Style="z-index: 100; left: 92px;
  29.             position: absolute; top: 393px" Text="Export to Excel using Response Object" />
  30.             </form>
Oct 17 '10 #1
0 1105

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by SASIKUMAR JP | last post: by
1 post views Thread by sasikumar | last post: by
1 post views Thread by sasikumar | last post: by
3 posts views Thread by sasikumar | last post: by
3 posts views Thread by sasikumar | last post: by
1 post views Thread by ctsasikumar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.