Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Documentation and tutorials > Unable to pass DataTable in Razor to instantiate a Grid

Answered Unable to pass DataTable in Razor to instantiate a Grid

Feed from this thread
  • Posted on Oct 9, 2011 (permalink)

    Requirements

    RadControls
    MVC VS Extensions 2011.02.712.0
    WebUI VSExtensions 2011.02.831.0

     

    .NET 4

     

    Visual Studio 2010

     

    C#

     

    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION                                    

    Just starting off using the controls.  Familar with MVC 3, asp.net 4
    Web Service for handling alot timeline content of pictures, text. 

    I have been going through the examples and searching the forums.  I have seen some close examples,  but after several hours. I'm stuck

    The issue is that I get a DataTable back from a DAL.DLL.  I want to hand that to the Telerik.Grid and have it displayed.

    The datatable is ok, i pass it and to the View(datatable)  and run into my first issue.
    Not able to cast this datatable into something Razor View will pass to the Telerik Grid.

    Inside some of your code examples the "GridModel" takes a DataTable, but unable to pass this to the View.
    So I went back to trying to use the DataTable.  One of your example is the form show passing a DataTable, it was in aspx not Razor syntax. But it didn't work. 

    Below is code pattern i have distilled it down to after several tries.

    Thanks Larry

     

    I keep getting an error on the site

     

    Controller Code------------------

     

    DataTable dtProjectTable = Test.DAL.Project.ListMyProjects(guidName.ProviderUserKey.ToString());
     

    Return View(dtProjectTable );

     

    View Code-------------------

     

    @model ????????????????????????  <-- here's where I fail

     

     

    @{ Html.Telerik().Grid(Model)
            .Name(
    "Grid")
            .Columns ( columns =>
            {
               columns.Bound(o => o.Name);
               columns.Bound(o => o.Modified)
            })
            .Sortable()
            .Scrollable()
            .Pageable()
            .Render();
    }

     

     



    Reply

  • Answer Atanas Korchev Atanas Korchev admin's avatar

    Posted on Oct 10, 2011 (permalink)

    Hi Ken Lassesen,

     Have you tried specifying System.Data.DataTable as the model of your view?

    Greetings,
    Atanas Korchev
    the Telerik team
    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 Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

    Reply

  • Posted on Oct 16, 2011 (permalink)

    Thanks that worked.
     
    Plus had to add @using System.Data in the Razor file. 


    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Documentation and tutorials > Unable to pass DataTable in Razor to instantiate a Grid