On Jun 23, 9:52 pm, "Lloyd Sheen" <a...@b.cwrote:
I have a repeater that will have linkbuttons. I have googled much but
cannot find a solution to the following.
Since the items are dynamic I need to be able to attach handlers to the
linkbuttons to handle when they are clicked within server code. I can find
no examples of this.
Any examples?
Thanks
Lloyd Sheen
Hi...
1. Add Link Button in ItemTemplate of reapeater
2. then add a commad name in the link attribute,.,,,
3. Subscribe the ItemDataBound to customize the items more
4. Subscribe the ItemCommand and then do code for link button
clicked...
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<!--More data bound code will go here-->
<asp:LinkButton ID="lnkSelect" Text="Select"
CommandName="Select" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
LinkButton btn = e.Item.FindControl("lnkSelect") as
LinkButton;
}
}
protected void Repeater1_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Select")
{
//do code
}
}
Thanks
Masudur
http://munnacs.110mb.com