Most of the functionality is implemented through template columns, in order to easily select and delete the use of its own features and methods, it is easy to achieve, did not find any major problems, but in the deployment to the server, found that the choice is not to display text, but "select", also did not find out what the reason, The following have to be implemented by template columns instead.
When changing to a template column implementation, found that the Gv_sjy_rowcommand event can not get the index of the row through E.commandargument, can only think of ways, found that there are two ways to do:
First Type:
Copy Code code as follows:
<asp:linkbutton id= "Btnselect" runat= "Server" causesvalidation= "False" commandname= "select" text= "Choose" Commandargument= "<%# (gridviewrow) Container). RowIndex%> "></asp:LinkButton>
Add a red section to the background to pass int rowIndex = Convert.ToInt32 (e.commandargument); Get the index value of the row
The second type:
Copy Code code as follows:
protected void Gv_sjy_rowcommand (object sender, Gridviewcommandeventargs e)
{
if (E.commandname = = "Select")
{
GridViewRow Gvrow = (GridViewRow) ((LinkButton) e.commandsource). Parent.parent);
int rowIndex = gvrow.rowindex;//Gets the selected row index
Txtsjyxh.text = DT2. rows[rowindex]["Sjyxh"]. ToString ();
}
}