public string myJsVar;
public string z_MyFunction()
{
string jsonCircles;
DataTable yourTable= new DataTable();
string conString = (ConfigurationManager.ConnectionStrings["yourConnectionString"].ConnectionString);
using (SqlConnection _con = new SqlConnection(conString))
using (SqlCommand _cmd = new SqlCommand("yourStoredProcedure", _con))
{
_cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter _dap = new SqlDataAdapter(_cmd);
_dap.Fill(yourTable);
DataSet dataSet = new DataSet("dataSet");
dataSet.Namespace = "NetFrameWork";
dataSet.Tables.Add(yourTable);
dataSet.AcceptChanges();
jsonCircles = JsonConvert.SerializeObject(yourTable, Formatting.Indented);
return jsonCircles.ToString();
}
}
e.g. yourStoredProcedure example Select * FROM yourDatabaseTable
protected void Page_PreRender(object sender, EventArgs e)
{
myJsVar = z_MyFunction();
}
Add this to ASPX page var dataX = <%= myJsVar %>;