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

Unable to pass DataTable in Razor to instantiate a Grid

2 Answers 59 Views
Documentation and tutorials
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ken Lassesen
Top achievements
Rank 2
Ken Lassesen asked on 10 Oct 2011, 01:28 AM

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();
}

 

 



2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 10 Oct 2011, 10:11 AM
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
0
Ken Lassesen
Top achievements
Rank 2
answered on 16 Oct 2011, 07:12 PM
Thanks that worked.
 
Plus had to add @using System.Data in the Razor file. 


Tags
Documentation and tutorials
Asked by
Ken Lassesen
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Ken Lassesen
Top achievements
Rank 2
Share this question
or