Anyone suggest me what is the best way to read bult data from DataTable and return as Json Multidimensional array to view...
I am using currently following...
- public JsonResult GetAllCategory()
- {
- List
string , object>> datarow = DataTableToList(new CategoryBAL().GetCategoryForEdit()); - new JavaScriptSerializer().Serialize(datarow);
- return Json(datarow, JsonRequestBehavior.AllowGet);
- }
- public List
string, object>> DataTableToList(DataTable dt) - {
- List
string , object>> parentRow = new Liststring, object>>(); - foreach (DataRow row in dt.Rows)
- {
- Dictionary<string, object> childRow = new Dictionary<string, object>();
- foreach (DataColumn col in dt.Columns)
- {
- childRow.Add(col.ColumnName, row[col]);
- }
- parentRow.Add(childRow);
- }
- return parentRow;
- }
Is there any other faster and optimized way to do this?

KanakPosted Apr 29, 2017, 6:40 AM