Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


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:

Click here to copy the following block
<TemplateColumn>
  <ItemTemplate>
    <asp:HyperLink Runat="server" NavigateUrl='<%# _
     "Details.aspx?EmployeeID=" & Container.DataItem("ID") & _
     "&EmployeeName=" & Container.DataItem("FirstName") %>' />
  </ItemTemplate>
</TemplateColumn>

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:

Click here to copy the following block
<TemplateColumn>
  <ItemTemplate>
   <asp:HyperLink Runat="server" NavigateUrl='<%# _
     BuildUrlWithQueryString("Details.aspx", _
     "EmployeeID", Container.DataItem("ID"),
     "EmployeeName", Container.DataItem("FirstName")) %>' />
  </ItemTemplate>
</TemplateColumn>



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.