The LinkButton of the GridView template passes multiple parameters

Source: Internet
Author: User
Tags bind eval

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

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.