ASP.Net Repeater
Neselere ulaşıp olay çalıştırma ve deger alma pratik yol
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ContactName") %>'></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick = "Button_Click" CommandArgument = '<%#Eval("ContactID") %>' />
</ItemTemplate>
</asp:Repeater>
Above you might have noticed that the ASP.Net Repeater control has a Button which when clicked raises a button click event.
Get Repeater Item and Repeater Item Index when Button is clicked
Below code explains how to get the ASP.Net Repeater Item, ItemIndex, Button reference and its CommandArgument.
C#
protected void Button_Click(object sender, EventArgs e)
{
//Get the reference of the clicked button.
Button button = (sender as Button);
//Get the command argument
string commandArgument = button.CommandArgument;
//Get the Repeater Item reference
// RepeaterItem item = button.NamingContainer as RepeaterItem;
//Get the repeater item index
//int index = item.ItemIndex;
}
LinkButton
C#
(sender as LinkButton);
VB.Net
CType(sender, LinkButton)
ImageButton
C#
(sender as ImageButton);
VB.Net
CType(sender, ImageButton)
Hiç yorum yok:
Yorum Gönder