Access to other properties of the repeater for data recovery in the codec

I have a repeater associated with a data source, in the itemtemplate for a repeater I have a link button

im using things like:

<% # Eval ("myfield")%>

to get data for an item.

I need a link button, which, when clicked, can access all the properties related to this element in the onclick event handler in the backend.

how can I access the other properties of the paticular element when the button in the itemtemplate element is clicked.

thanks

+3
source share
1 answer

You can:

CommandArgument, ,

<asp:LinkButton runat="server" OnCommand="MyButton_Command" CommandArgument='<%# Eval("MyObjectId") %>'/>

protected void MyButton_Command(object sender, CommandEventArgs e)
{
    int myId = int.Parse(e.CommandArgument.ToString());
    // Load the object using the id passed in
}

"" LinkButton, RepeaterItem ... ,

+1

Source: https://habr.com/ru/post/1720057/


All Articles