Weird exception in linkbutton in a datalist

Posted by user308806 on Stack Overflow See other posts from Stack Overflow or by user308806
Published on 2010-04-17T13:33:18Z Indexed on 2010/04/17 13:53 UTC
Read the original article Hit count: 601

Filed under:
|
|

Dear all, I have written this datalist :

       <div class="story" runat="server">
   <asp:DataList ID="DataList2" runat="server" Height="16px" Width="412px">
                  <SeparatorTemplate>
                    <hr />
                  </SeparatorTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat ="server" Text='<%# Eval("Name") %>' PostBackUrl='<%#Eval("Url")%>' />          
                    <br />
                  Description:
                  <asp:Label ID="new" Text='<%#Eval("Description") %>' runat="server" />                  </ItemTemplate>
              </asp:DataList>




      </div>

It raises an exception saying that the linkbutton has to be placed in a tag that contains runat="server" although it exists. Here is the trace

[HttpException (0x80004005): Le contrôle 'DataList2_ctl00_LinkButton1' de type 'LinkButton' doit être placé dans une balise form avec runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8689747
   System.Web.UI.WebControls.LinkButton.AddAttributesToRender(HtmlTextWriter writer) +39
   System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +20
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +20
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   System.Web.UI.WebControls.DataListItem.RenderItemInternal(HtmlTextWriter writer, Boolean extractRows, Boolean tableLayout) +51
   System.Web.UI.WebControls.DataListItem.RenderItem(HtmlTextWriter writer, Boolean extractRows, Boolean tableLayout) +57
   System.Web.UI.WebControls.DataList.System.Web.UI.WebControls.IRepeatInfoUser.RenderItem(ListItemType itemType, Int32 repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) +64
   System.Web.UI.WebControls.RepeatInfo.RenderVerticalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) +262
   System.Web.UI.WebControls.RepeatInfo.RenderRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) +27
   System.Web.UI.WebControls.DataList.RenderContents(HtmlTextWriter writer) +208
   System.Web.UI.WebControls.BaseDataList.Render(HtmlTextWriter writer) +30
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#