asp.net pass multiple values to other pages of the specific implementation _ practical skills

Source: Internet
Author: User
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"];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.