Html helper bynamic table bind for DataTable and generic list model
Html Helper with DataTable public static MvcHtmlString ToHtmlTable( this HtmlHelper html, DataTable dataTable) { StringBuilder tempTableSb = new StringBuilder (); if (dataTable != null && dataTable.Rows.Count > 0) { tempTableSb.Append( "<table class='table table - responsive table - bordered'>" ); tempTableSb.Append( "<thead><tr>" ); foreach ( DataColumn col in dataTable.Columns) { tempTableSb.Append( "<th>" + col.Caption + "</th>" ); } tempTableSb.Append( "</tr></thead><tbody>" ); foreach ( DataRow row in dataTable.Rows) { tempTableSb.Append( "<tr>" ); foreach ( var cell in row.ItemArray)