In web development, jumps between pages are often used to pass values, which may pass multiple values.
One, Commadargument pass multiple values to other pages.
In data-bound controls such as the GridView DataList Repeater, you can use Commadargument to pass multiple values.
The source code (ASPX page code) is as follows: This code is generally written in the item template, if you use the first method does not need to add onclick event, directly click on the data-bound control Rowcommand, ItemCommand event, on the line.
Copy Code code as follows:
<asp:imagebutton id= "Editimagebutton" runat= "imageurl=" ~/images/bt_edit.gif "commandargument=" <%# Eval ("dict_id") + "," +eval ("Dict_type")%> ' onclick= "Editimagebutton_click" height= "" width= "
Method 1, if you use the GridView control, find the Rowcommand event double-click, use the Datalist,repeater control to find the ItemCommand event double-click, the background code is as follows:
Copy Code code as follows:
Object[] Arg=e.commandargument.tostring (). Split (', '); Note that single quotes
String arg0=arg[0]. ToString ();
String arg1=arg[1]. ToString ();
Method 2, put the LinkButton control in the item template. This is more commonly used, you do this control plus the onclick event. The following table code is as follows:
Copy Code code as follows:
LinkButton lbt= (LinkButton) sender;
Object[] Arg=lbt.commandargument.tostring.split (', ');
String arg0=arg[0]. ToString ();
String arg1=arg[1]. ToString ();
Second, the use of hyperlinks to transfer values, but also a common method
Foreground code:
Copy Code code as follows:
<a href= "default.aspx?id=<% #Eval (" dict_id ")%>&type=<% #Eval (" Dict_type ")%>" > Skip to Default.aspx page </a>
Background:
Copy Code code as follows:
String strdict_id = request.querystring["dict_id"];
String strdict_type= request.querystring["Dict_type"];