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

Model not available in view page

1 Answer 93 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, 10:30 AM
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WeBOC.DAL.Vessel>" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<script runat="server">
 
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = ViewData["Vessels"];               
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
    <form id="form2">
     
 
    <h2>Vessels<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    </h2>
     
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
        CellSpacing="0" GridLines="None" Skin="WebBlue"
        onneeddatasource="RadGrid1_NeedDataSource" AllowPaging="True"  PagerStyle-Mode="NextPrevNumericAndAdvanced">
        <MasterTableView>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="VIR_NO" HeaderText="VIR No." />
                <telerik:GridBoundColumn DataField="INBOUND_VOY_NO" HeaderText="I/B Voyage" />
                <telerik:GridBoundColumn DataField="OUTBOUND_VOY_NO" HeaderText="O/B Voyage" />
                <telerik:GridBoundColumn DataField="VESSEL_NAME" HeaderText="Vessel Name" />
                <telerik:GridBoundColumn DataField="ARRIVAL_DATE" HeaderText="Arrived" />
                <telerik:GridBoundColumn DataField="STATE" HeaderText="Phase" />               
                <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column"
                    UniqueName="TemplateColumn">
                    <ItemTemplate>
                            <asp:HyperLink ID="HyperLink1" runat="server" Text="View"
                            NavigateUrl='<%#Url.Action("Inspector","Vessel",new{id=Modal.VSSL_CALL_ID}) %>'></asp:HyperLink>
                        </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
        </MasterTableView>
 
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
 
    </telerik:RadGrid>
 
     
    </form>
 
</asp:Content>


Have a look at the above code, when it runs, it stuck at  NavigateUrl='<%#Url.Action("Inspector","Vessel",new{id=Modal.VSSL_CALL_ID}) %>'>

and says that object reference not set to an instance of an object. How do i achieve the functionality that when i click on this hyperlink, the id of the selected row will pass to the desired controller?

Thanks
Ovais

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 05 Jul 2013, 06:38 AM
Hi,

ASP.NET Web Forms and ASP.NET MVC are different architectures and thus are using different controls. Using controls designed for one architecture is not supported scenario. RadGrid for ASP.NET Ajax could not be used to transfer any values to the controller. In order to achieve your goal you should use RadControls for ASP.NET MVC.

Regards,
Andrey
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
Andrey
Telerik team
Share this question
or