ASP.Net Problem with Event Handlers and Control Creation Timing

Posted by Oliver Weichhold on Stack Overflow See other posts from Stack Overflow or by Oliver Weichhold
Published on 2010-04-23T08:19:36Z Indexed on 2010/04/23 8:23 UTC
Read the original article Hit count: 282

Filed under:

What I am trying to achieve here is to display a number of LinkButtons in a RadGrid Column. The buttons are generated from a collection property member of the bound grid row item.

The CollectionLinkButton control is nothing more than a asp:Panel derived control that populates its Child Controls from "DataItem.SomeCollection" and this is working fine. The problem I am facing is with this part: Collection='<%# DataBinder.Eval(Container, "DataItem.SomeCollection") %>'

This is because databound Collection Property is populated so late in the lifecycle of the page that the LinkButton Controls that the CollectionLinkButton class creates from the collection are not available yet during Postback when the Click event Handler is supposed to fire and I have currently no idea how to solve this problem.

<radG:RadGrid ID="grid" runat="server" DataSourceID="ds_AB">
  <MasterTableView>
    <Columns>
      <radG:GridTemplateColumn>
        <ItemTemplate>
          <local:CollectionLinkButton ID="LinkButton1" runat="server" CssClass="EntityLinkButton"
            Collection='<%# DataBinder.Eval(Container, "DataItem.SomeCollection") %>'
            CollectionProperty="Id" CollectionDisplayProperty="Name"
            Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>'</local:CollectionLinkButton>
        </ItemTemplate>
      </radG:GridTemplateColumn>

© Stack Overflow or respective owner

Related posts about ASP.NET