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

Binding Navigate URL Within A RadGrid ItemTemplate

1 Answer 259 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Huw
Top achievements
Rank 1
Huw asked on 25 Mar 2009, 04:43 PM
Hi,

I have a RadGrid and I am using the ItemTemplate to display the data in a table format for each record of data. This allows me to set it out how I want it.

In my table I have included a Rad Menu which I want to use to give the user a number of options. I am having difficulty in assigning the NavigateURL of each menu item. For example I have a button with Text "Edit Details" and I want this to like through to a page called

EditDetails.aspx?ItemID=##

where ## is the ID of the unigue record ID as stored in the database.

I found this post

Binding NavigateURL within a RadGrid won't work

Which is extreemly useful, however the example given has the menu in a GridTemplateColumn, whilst mine is not in a GridTemplateColumn but rather is in an ItemTemplate

When I replicate the code I get the link

EditDetails.aspx?ItemID=

but it does not bring through the ID of the column itself and add it to the address





How do I adjust the code for the example above so that it works for an ItemTemplate, rather than for a GridTemplateColumn

Many thanks in advance



1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 31 Mar 2009, 07:48 AM
Hi Huw,

To see more information on the matter, please refer to the following example. The id is passed as an argument to the client side function:

 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");  
                editLink.Attributes["href"] = "#";  
                editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"], e.Item.ItemIndex);  
            }  
        }  
 

I hope this suggestion gets you started properly.

Best wishes,
Yavor
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Huw
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or