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

Telerik RadGridHyperLinkColumn with Url.Action Method in MVC

2 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Muhammad asked on 02 Jul 2013, 12:34 PM
Hi,
I've a controller which passes data to the strongly typed view of type IEnumerable. Here, i used a blank template and put my own RadGrid. I've successfully bind the rad grid with the model.
I've added a hyper link column and the purpose is, when i click on hyperlink, the id of the clicked row will be pass to another view. Have a look at below:

<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" UniqueName="TemplateColumn">
    <ItemTemplate>
            <asp:HyperLink ID="HyperLink1" runat="server" Text="View"
                            NavigateUrl='<%# Url.Action("Inspector","Vessel",new{id=Model.Id}) %>'>
        </asp:HyperLink>
        </ItemTemplate>
</telerik:GridTemplateColumn>


When i run the application, error appears. I just want to know how to achieve the above defined functionality. I know i can't use "Modal.Id".. What is the other way?

Thanks
Ovais

2 Answers, 1 is accepted

Sort by
0
Muhammad
Top achievements
Rank 1
answered on 03 Jul 2013, 06:32 AM
Still waiting for a positive response. Required urgently.
0
Marin
Telerik team
answered on 05 Jul 2013, 09:14 AM
Hi,

 RadGrid is designed as an ASP.NET AJAX control and may experience some limitation when used in the life cycle of a different web framework such as ASP.NET MVC. 
The error in the case of your configuration is probably caused by the data-binding expression that you use in the asp:HyperLink control in the template column. If the ViewData.Model property is not initialized by the time the data-binding expression of the column is evaluated you may get errors.
Another option is to try using the ASP.NET AJAX way of accessing the properties of the underlying binding object through the use of Eval or DataBind, if they are available in this context then manually build up the necessary view URL in this case.
Normally the syntax with Model.PropertyName should be working from anywhere in the View if they are setup correctly and if the control is databound properly, so this approach should also be viable in this case.

Regards,
Marin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Muhammad
Top achievements
Rank 1
Answers by
Muhammad
Top achievements
Rank 1
Marin
Telerik team
Share this question
or