This is a migrated thread and some comments may be shown as answers.

GridHyperLinkColumn - Including a request.querystring variable?

3 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 06 Jul 2010, 10:23 AM
Hi,

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

Can anyone help?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2010, 11:02 AM
 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.
0
Steven
Top achievements
Rank 1
answered on 06 Jul 2010, 11:18 AM
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.
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Jul 2010, 10:53 AM
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.


Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Steven
Top achievements
Rank 1
Share this question
or