Passing parameters through the LinkButton of the GridView template, it is common to pass a parameter, but it is possible to pass multiple parameters.
The code in. aspx is:
<asp:templatefield headertext= "Course number" sortexpression= "course number" > <ItemTemplate> <asp:linkbutton id= " Linkbuttoncourseno "runat=" server "text= ' <%# Bind (" course number ")%> ' commandname= ' buttonclick ' commandargument= ' <% # Eval ("ID") + "," +eval ("course name") + "," +eval ("approved")%> ' ></asp:LinkButton> </ItemTemplate> </ Asp:templatefield>
The. CS code is:
protected void Gviewoutlinelist_rowcommand (object sender, Gridviewcommandeventargs e) {if (E.commandname = =) ButtonClick ") {//response.write (e.commandargument.tostring ()), object [] arguments = e.commandargument.tostring (). Split (', '); Response.Write (arguments. Length.tostring ()); int Outlineid = Convert.ToInt32 (e.commandargument); Response.Redirect ("A.aspx? Outlineid= "+convert.toint32 (Arguments[0]) +" &coursename= "+arguments[1]. ToString () + "&stateapproved=" +convert.toint32 (arguments[2]); } }
If you bind data with bind () in an. aspx file, the resulting arguments. Length is 1, do not get the desired results, the problem I have not figured out, have to know the message to me AH.
Another way is to get the line number in the background Rowcommand event, and then to access the column values according to the line number, but this method I haven't tried O (∩_∩) o~
Reference: http://www.cnblogs.com/kuitar/archive/2009/07/03/1516163.html