How to set multiple parameters for a link in a DataGrid

Source: Internet
Author: User
Tags eval tostring
datagrid| link when using the DataGrid if you have a asp:hyperlinkcolumn and want to use multiple parameters that need to be bound as a link URL, change to a template column, using the generic link tag <a> or asp: Hyperlink, here are 2 solutions to implement multiple-binding parameters. The same is true of http://blog.csdn.net/lovecherry/archive/2005/02/25/301441.aspx.
(1) Background return URL
Front desk
<asp:templatecolumn headertext= "Open" >
<ItemTemplate>
<asp:hyperlink text= "Open" Navigateurl= ' <%# myfunc2 (DataBinder.Eval (Container.DataItem, "VName"), DataBinder.Eval (Container.DataItem, "iage"))%> ' runat= ' server ' target= ' _blank ' id= ' Hyperlink1 ' >
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
Background
Protected string Myfunc2 (object S1,object s2)
{
Return "Newpage.aspx?name=" +s1. ToString () + "&age=" +s2. ToString ();
}
(2) direct foreground set URL
<asp:templatecolumn headertext= "Open" >
<ItemTemplate>
<asp:hyperlink text= "Open" Navigateurl= ' <%# "newpage.aspx?name=" +databinder.eval (Container.DataItem, "vname") + "&age=" +databinder.eval (Container.DataItem, "iage")%> ' runat= ' server ' target= ' _blank ' >
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

In fact, the above 2 scenarios is one thing, but the former is more clear, and easy to dynamically generate the background URL.





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.