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

Adding parameters to GridHyperLinkColumn during ItemDataBound

2 Answers 722 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bdk0172
Top achievements
Rank 1
bdk0172 asked on 11 Jun 2010, 09:54 PM
I have a hyperlink column in my radgrid:

<

 

telerik:GridHyperLinkColumn Target="_parent" HeaderText="ID" DataTextField="volunteer_id" DataNavigateUrlFormatString="VolunteerEdit.aspx?Id={0}&amp;type=edit" DataNavigateUrlFields="volunteer_id" UniqueName="volunteer_id"></telerik:GridHyperLinkColumn>

 


I'd like to be able to add more URL parameters to the DataNavigateUrlFormatString at runtime during the ItemDataBound event.  How do I accomplish this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Jun 2010, 06:28 AM
Hello,

You can try the following approach in order to change the url parameter based on row value.

aspx:
 
<telerik:GridHyperLinkColumn Target="_parent" HeaderText="ID" DataTextField="volunteer_id" 
    UniqueName="volunteer_id"
</telerik:GridHyperLinkColumn> 

cs:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string val1 = item["volunteer_id"].Text; 
            HyperLink hLink = (HyperLink)item["volunteer_id"].Controls[0]; 
            hLink.NavigateUrl = "VolunteerEdit.aspx?Id="+val1+"&type=edit"
        } 
    } 


-Shinu.
0
bdk0172
Top achievements
Rank 1
answered on 14 Jun 2010, 04:17 PM
Thanks for your reply.  I had to actually add more parameters to the URL string instead of changing the one that was already there, but you got me pointed in the right direction.
Tags
Grid
Asked by
bdk0172
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
bdk0172
Top achievements
Rank 1
Share this question
or