ASP.Net Problem with Event Handlers and Control Creation Timing
- by Oliver Weichhold
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>