• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1031
  • Last Modified:

'DataGridLinkButton' must be placed inside a form tag with runat=server

Hi experts:

I have a web page that queries database according to the user's input and bind the resulting data set to a DataGrid. It has been working fine until today after I changed the DataGrid property to AllowSorting=true and added some code to cache the resulting data set and to handle DataGridSortCommandEvent. The error message is as below. Can anyone point me to probable causes?  I have the DataGrid create columns automatically at runtime and there's no link button in the DataGrid. Thanks.

[HttpException (0x80004005): Control '<myTable>__ctl1__ctl0' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +152
   System.Web.UI.WebControls.LinkButton.AddAttributesToRender(HtmlTextWriter writer) +38
   System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +17
   System.Web.UI.WebControls.DataGridLinkButton.Render(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer) +55
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +7
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer) +99
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +7
   System.Web.UI.WebControls.BaseDataList.Render(HtmlTextWriter writer) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.Control.Render(HtmlTextWriter writer) +7
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Page.ProcessRequestMain() +1926
0
sdc248
Asked:
sdc248
  • 2
  • 2
1 Solution
 
naveenkohliCommented:
Did you accidently delete "FORM" tag from your page?
0
 
sdc248Author Commented:
Oh, the <asp:datagrid...> control IS out side of the <form></form> tags. I moved it in and it's working now. But why? It doesn't seem to matter until I enable the "AllowSorting" functionality?
0
 
naveenkohliCommented:
As long as no post back action related to FORM was happening your page did not complain. But the moment you added the event for link buttons, their action type is "submit" which requires FORM tag on the page.
0
 
sdc248Author Commented:
Got you. Thanks a lot.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now