Unable to bind dynamic DataTable to Grid.MVC
I want to use Grid.MVC to create a grid (table). In this grid I want to bind to a DataTable, which is the Table I get from SELECT * FROM TABLE
My view looks like this:
@model DataTable @{ ViewBag.Title = "ViewTable"; } @using GridMvc.Html @using System.Data >()).Columns(columns => { columns.Add().RenderValueAs(a => Html.ActionLink("Edit", "Index")); foreach (DataColumn item in Model.Columns) { try { columns.Add(a => item).Titled(item.ColumnName); } catch (Exception) { throw; } } })
ViewTable
@Html.Grid(Model.Columns.CastThis always throws the error column item already exists in the grid (at the second item).

Sanwar RanwaRank #23 · 44.7K reputationPosted May 20, 2019, 8:12 PM EDT
Madan ShekarRank #428 · 5.9K reputationPosted May 20, 2019, 9:43 PM EDT
greeshma kb15 reputationPosted May 21, 2019, 7:22 PM EDT
Gajendra JangidRank #157 · 14.9K reputationPosted Jun 3, 2019, 8:50 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 3, 2019, 9:22 PM EDT
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 22, 2019, 7:46 AM EST