C# GridView: add LinkButton and focus selected row
There are some tricks with GridView control on Asp.net. It's really cool tool if you know it. The tricks are about how to add LinkButton to each row and how to focus the GridViewRow where LinkButton was clicked.
You can add custom LinkButton to each row of GridView control in .aspx page this way:
Add LinkButton to GridView
<asp:LinkButton ID="selectRecord" runat="server" Text="Show" CommandName="Select" CommandArgument='<%# Eval("ID") %>' />
If you want to focus the row on RowCommand event, you should use the code like this:
Focus selected Row in GridView
GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int rowIndex = gvr.RowIndex;
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL