GridHyperLinkColumn - Including a request.querystring variable?

4 posts, 1 answers
  1. Steven
    Steven avatar
    26 posts
    Member since:
    May 2009

    Posted 06 Jul 2010 Link to this post

    Hi,

    I need to include a request.querystring variable in the DataNavigateUrlFormatString but I am not sure how to do it?

    Can anyone help?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Jul 2010 Link to this post

     Hello Steven,

    In order to achieve this, set the DataNavigateUrlFields property of GridHyperLinkColumn. You can then combine the navigate URL fields by specifying a format string as the value of the DataNavigateUrlFormatString property. Please refer the section "GridHyperLinkColumn" in the following documentation which explains the same.

    Column types

    Thanks,
    Princy.
  3. Steven
    Steven avatar
    26 posts
    Member since:
    May 2009

    Posted 06 Jul 2010 Link to this post

    Hi Princy,

    Sorry I don't think I was clear in my original request.  I have an existing variable on the URL called 'db'  I need to include this on the link.

    <telerik:GridHyperLinkColumn  
      DataNavigateUrlFields="ProjectKey, LocationKey"  
      DataNavigateUrlFormatString="../Recruitment-data.aspx?projectid={0}&locationid={1}"  
      UniqueName="InvestigatorSelect"  
      Text="Select"  
      Visible="False"  
      target="_top"
    </telerik:GridHyperLinkColumn> 

    This is what I have currently but I need to append this with the existing variable from the URL, I thought I may have been able to edit the DataNavigateURLFields by doing something like:

    DataNavigateUrlFormatString="../Recruitment-data.aspx?projectid={0}&locationid={1}<%# iif(len(request.querystring("db")) > 0, "&db=" & request.querystring("db"), "") %>"  


    but this just errors out.
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Jul 2010 Link to this post

    Hello Steven,

    You can achieve this from code behind. In ItemDataBound event access the HyperLink control and set its NavigateUrl property accordingly.

    ASPX:
      
      <telerik:GridHyperLinkColumn UniqueName="InvestigatorSelect" Text="Select" Visible="true" Target="_top"

    VB.NET:
     
     Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) 
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
            Dim rowView As DataRowView = DirectCast(item.DataItem, DataRowView) 
            Dim id As String = rowView("ProjectKey").ToString() 
            Dim name As String = rowView("LocationKey").ToString() 
            Dim link As HyperLink = DirectCast(item("InvestigatorSelect").Controls(0), HyperLink) 
            Dim v As String = Request.QueryString("db").ToString() 
            If v.Length > 0 Then 
                db = v 
            Else 
                db = "" 
            End If 
            link.NavigateUrl = "../Recruitment-data.aspx?projectid={0}&locationid={1}" & "db=" & db 
        End If 
     End Sub 
     

    Thanks,
    Princy.


Back to Top