from the db returns a column's value named RSS_Title and when I click the it. I want to handle the row index of this value. How can i do it?
I tried some codes but it does not work
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click"><%#Eval("RSS_Title")%></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
you can use the below code in the LinkButton2_Click
event
protected void LinkButton2_Click(object sender, System.EventArgs e)
{
//Get the button that raised the event
LinkButton btn = (LinkButton )sender;
//Get the row that contains this button
GridViewRow gvr = (GridViewRow)btn.NamingContainer;
//Get rowindex
int rowindex = gvr.RowIndex;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.