Commandargument's method of transferring multiple values to another page

Source: Internet
Author: User

Use commadargument to transmit multiple values in data binding controls such as gridview datalist Repeater

SourceCodeAs follows (ASPX page code): This code is generally written in the item template. If you use the first method, you do not need to add an onclick event to directly click rowcommand of the data binding control. The itemcommand event will work.
<Asp: imagebutton id = "editimagebutton" runat = "server" imageurl = "~ /Images/bt_edit.gif "commandargument = '<% # eval (" dict_id ") +", "+ eval (" dict_type ") %> 'onclick = "editimagebutton_click" Height = "20" width = "20"/>

Method 1;
If you use the gridview control to find the datalist used by double-clicking the rowcommand event, the repeater control will find the itemcommand event double-click
The background code is as follows:

Object [] Arg = E. commandargument. tostring (). Split (','); // note that it is a single quotation mark.
String arg0 = Arg [0]. tostring ();
String arg1 = Arg [1]. tostring ();

Method 2: add the linkbutton control to the item template. You can manually add an onclick event to the control.
Linkbutton LBT = (linkbutton) sender;
Object [] Arg = LBT. commandargument. tostring. Split (',');
String arg0 = Arg [0]. tostring ();
String arg1 = Arg [1]. tostring ();
 

Method 3: Use a hyperlink to pass a value

<A href = "default. aspx? Id = <% # eval ("dict_id") %> & type = <% # eval ("dict_type") %> "> jump to the default. aspx page </a>

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.