This question is locked. New answers and comments are not allowed.
Hello, in your tutorial you show how to bind data to a grid if it is a Strongly Typed View. How do you bind data to a grid in a View that is not Strongly typed, and also if you have two datasources that you would like to bind to two separate grids....
4 Answers, 1 is accepted
0
Hello Leonard,
You can use ViewData dictionary to set your data and then in the View to pass it to the grid.
Check this blog for more information.
The second options is to create View Models, which will contains the two data sources required for the two grids. For more information you can review this blog.
Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You can use ViewData dictionary to set your data and then in the View to pass it to the grid.
Check this blog for more information.
The second options is to create View Models, which will contains the two data sources required for the two grids. For more information you can review this blog.
Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Tim
Top achievements
Rank 1
answered on 30 Apr 2010, 03:37 PM
Hello Georgi, thanks for your response. In the example you all use in the online help, this is how you declare the grid in the View:
For the Second option you mentioned, I don't understand how I set up my grid. Could you please help with the commands... My Model that I use for my View is this:
public class HomeViewModel
{
public IEnumerable<Program> mPrograms { get; private set; }
public IEnumerable<StationView> mStations { get; private set; }
public HomeViewModel(IEnumerable<Program> progms, IEnumerable<StationView> statns)
{
this.mPrograms = progms;
this.mStations = statns;
}
}
In the View I have: Inherits="System.Web.Mvc.ViewPage<EPLRS_WebApp.Controllers.HomeViewModel>" %>
I am getting errors setting up my grid in the View...
<% Html.Telerik().Grid<Order>() .Name("OrdersGrid") .BindTo(Model) .Columns(columns => { /*code to define the columns*/}}) .Pageable() .Sortable() .Render() %>
For the Second option you mentioned, I don't understand how I set up my grid. Could you please help with the commands... My Model that I use for my View is this:
public class HomeViewModel
{
public IEnumerable<Program> mPrograms { get; private set; }
public IEnumerable<StationView> mStations { get; private set; }
public HomeViewModel(IEnumerable<Program> progms, IEnumerable<StationView> statns)
{
this.mPrograms = progms;
this.mStations = statns;
}
}
In the View I have: Inherits="System.Web.Mvc.ViewPage<EPLRS_WebApp.Controllers.HomeViewModel>" %>
I am getting errors setting up my grid in the View...
0
Hello Leonard,
Unfortunately I am not able to understand where the problem could be. I will ask you to send us a working test project, which reproduces the depicted issue.
Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Unfortunately I am not able to understand where the problem could be. I will ask you to send us a working test project, which reproduces the depicted issue.
Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Tim
Top achievements
Rank 1
answered on 30 Apr 2010, 03:59 PM
Georgi, the main thing is, what parameter needs to go in the generic Grid declaration:
In this example you use the "Order" table, if I am using a Strongly typed View, what would be the parameter for the Grid<>
<% Html.Telerik().Grid<Order>() .Name("OrdersGrid") .BindTo(Model) .Columns(columns => { /*code to define the columns*/}}) .Pageable() .Sortable() .Render() %>
In this example you use the "Order" table, if I am using a Strongly typed View, what would be the parameter for the Grid<>