Most of the functions are implemented through the template column. To facilitate selection and deletion, the built-in functions and methods are used, which can be easily implemented without any major problems found; however, when deployed to the server, it is found that the selection is not text, but "select", and the reason is not found. It must be implemented through the template column later.
When changed to the template column implementation, it was found that the gv_sjy_rowcommand event could not get the row index value through E. commandargument. There are only two ways to do this:
First:
CopyCode The Code is as follows: <asp: linkbutton id = "btnselect" runat = "server" causesvalidation = "false" commandname = "select" text = "select" commandargument = "<% # (gridviewrow) container ). rowindex %> "> </ASP: linkbutton>
Add the red part before using int rowindex = convert in the background. toint32 (E. commandargument); obtain the index value of a row
type 2: copy Code the code is as follows: protected void gv_sjy_rowcommand (Object sender, gridviewcommandeventargs E)
{< br> If (E. commandname = "select")
{< br> gridviewrow gvrow = (gridviewrow) (linkbutton) E. commandsource ). parent. parent);
int rowindex = gvrow. rowindex; // obtain the selected row index
txtsjyxh. TEXT = dt2.rows [rowindex] ["sjyxh"]. tostring ();
}< BR >}