Reputation: 948
I have make a dynamic gridview in asp.net mvc3 view engine is aspx. i have to bind datasource gridview. how bind datasource to grid view. and i had to add templete in gridview.
Upvotes: 0
Views: 6483
Reputation: 2918
You could have found this answer yourself if you would do some research but here are some links that could help you:
http://weblogs.asp.net/andrebaltieri/archive/2010/11/01/asp-net-mvc-3-working-with-webgrid.aspx
http://www.unboxedsolutions.com/sean/archive/2011/01/23/15964.aspx
could be something like this:
@{
var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
grid.Bind(Model.Employees, rowCount: Model.TotalRecords, autoSortAndPage: false);
grid.Pager(WebGridPagerModes.All);
@grid.GetHtml(htmlAttributes: new { id="grid" },
columns: grid.Columns(
grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { EmployeeID = item.EmployeeID, ContactID = item.ContactID })),
grid.Column("FullName"),
grid.Column("Title")
));
}
Upvotes: 1
Reputation: 19872
Are you using MVC .NET or WebForms?
Which grid view are you talking about?
Have you seen these links:
Create GridView in asp.net MVC3.0
http://forums.asp.net/t/1687421.aspx/1?Gridview+in+MVC+3
Upvotes: 0