The example in this article describes the line number that asp.net gets listview and the current row in the GridView. Share to everyone for your reference, specific as follows:
aspx, in Gridview/listview, there is a template column called LinkButton, and when you click it, get the index value of the row it is in
In ListView:
First type:
<ItemTemplate>
<tr>
<td>
<asp:linkbutton runat= "Server" id= "btnselected" text= " <%# (container.displayindex+1). ToString ()%> ' ></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
The second type:
<ItemTemplate>
<li>
<asp:linkbutton id= "Btndelete" runat= "Server" Commandname= "Delete"
text= "<%# container.dataitem%>" ></asp:LinkButton>
</li>
</itemtemplate >
In the GridView
First type:
<itemtemplate>
<asp:linkbutton id= "LinkButton1" runat= "Server"
</itemtemplate>
protected void LinkButton1_Click (object sender, EventArgs e)
{
//line number
int row = ((GridViewRow) ((LinkButton) Sender). NamingContainer). RowIndex;
}
The second type:
<asp:gridview id= "gvtest" runat= "Server" >
<Columns>
<asp:TemplateField>
< Itemtemplate>
displayindex: <%# container.displayindex%> | | Dataitemindex: <%# container.dataitemindex%><br/>
</ItemTemplate>
</asp: templatefield>
</Columns>
</asp:GridView>
I hope this article will help you to ASP.net program design.