{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
using (SqlCommand cmd = new SqlCommand("Select * from TM_Product_Details", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List
Dictionary
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
//Context.Response.Write(js.Serialize(rows));
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize(new { All_Product_Data = rows }));
}
else
{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
this.Context.Response.ContentType = "application/json; charset=utf-8";
this.Context.Response.Write(serializer.Serialize("No Record Found !!!"));
}
}
}

Jitendra ShekhawatRank #1,909 · 772 reputationPosted Mar 23, 2017, 1:30 AM EDT
[HttpPost]public JsonResult DeleteClientRecord(){ bool result = true; trycatch (Exception ex){ return Json(new { Success="False", responseText=ex.Message});return Json(new { result }, JsonRequestBehavior.AllowGet);Jitendra ShekhawatRank #1,909 · 772 reputationPosted Mar 23, 2017, 1:31 AM EDT
Abhishek Srivastava58 reputationPosted Mar 23, 2017, 4:09 AM EDT