'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
sdc248Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

naveenkohliCommented:
Did you accidently delete "FORM" tag from your page?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.