Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB7
Expertise: Intermediate
Feb 24, 2003



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Creating DataGrid's hyperlink columns with multiple parameters in the Url

The DataGrid's HyperLinkColumn column is great to have a column with an hyperlink that points to an Url with a parameter whose value is taken from the data source, but what if you need to build the target Url with more than one parameter taken from the data source? In this case you can use a template column as follows:

       <asp:HyperLink Runat="server" NavigateUrl='<%# _
          "Details.aspx?EmployeeID=" & Container.DataItem("ID") & _
          "&EmployeeName=" & Container.DataItem("FirstName") %>' />

Instead of doing the string concatenation yourself you can use the BuildUrlWithQueryString function, which must be declared with Public/Protected visibility in the code-behind, as follows:

      <asp:HyperLink Runat="server" NavigateUrl='<%# _
         BuildUrlWithQueryString("Details.aspx", _
         "EmployeeID", Container.DataItem("ID"),
         "EmployeeName", Container.DataItem("FirstName")) %>' />

Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date