Displaying data from database using javascript.
-
Hi, I would like the javascript to show data from getData method (webMethod), when the page loads but when filter the data (categoryPicker control), using webMethod getData2. This is currently my c# page.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{JavaScriptSerializer jss = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jss.Serialize(GetData()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } else { JavaScriptSerializer jtt = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jtt.Serialize(GetData2()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } } \[WebMethod\] public static List GetData() { SqlConnection conn = new SqlConnection("#####"); DataSet ds = new DataSet(); DataTable dt = new DataTable(); conn.Open(); var yesterday = DateTime.Today.AddDays(-1); string cmdstr = "select top 500 Name, \[Decimal price\],Cover, UploadDate from \[dbo\].\[database\] order by UploadDate desc"; SqlCommand cmd = new SqlCommand(cmdstr, conn); //cmd.Parameters.AddWithValue("@value", yesterday); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds);
-
Hi, I would like the javascript to show data from getData method (webMethod), when the page loads but when filter the data (categoryPicker control), using webMethod getData2. This is currently my c# page.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{JavaScriptSerializer jss = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jss.Serialize(GetData()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } else { JavaScriptSerializer jtt = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jtt.Serialize(GetData2()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } } \[WebMethod\] public static List GetData() { SqlConnection conn = new SqlConnection("#####"); DataSet ds = new DataSet(); DataTable dt = new DataTable(); conn.Open(); var yesterday = DateTime.Today.AddDays(-1); string cmdstr = "select top 500 Name, \[Decimal price\],Cover, UploadDate from \[dbo\].\[database\] order by UploadDate desc"; SqlCommand cmd = new SqlCommand(cmdstr, conn); //cmd.Parameters.AddWithValue("@value", yesterday); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds);
Need more details inorder to understand your requirement. Can you please clarify little bit more in detail.
-
Hi, I would like the javascript to show data from getData method (webMethod), when the page loads but when filter the data (categoryPicker control), using webMethod getData2. This is currently my c# page.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{JavaScriptSerializer jss = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jss.Serialize(GetData()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } else { JavaScriptSerializer jtt = new JavaScriptSerializer(); ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript", //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>", string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>", jtt.Serialize(GetData2()), "Name Example", "Name", "Type Example", "Type Example", "Type,")); } } \[WebMethod\] public static List GetData() { SqlConnection conn = new SqlConnection("#####"); DataSet ds = new DataSet(); DataTable dt = new DataTable(); conn.Open(); var yesterday = DateTime.Today.AddDays(-1); string cmdstr = "select top 500 Name, \[Decimal price\],Cover, UploadDate from \[dbo\].\[database\] order by UploadDate desc"; SqlCommand cmd = new SqlCommand(cmdstr, conn); //cmd.Parameters.AddWithValue("@value", yesterday); SqlDataAdapter adp = new SqlDataAdapter(cmd); adp.Fill(ds);
Need more details inorder to understand your requirement. Can you please clarify little bit more in detail.
-
Need more details inorder to understand your requirement. Can you please clarify little bit more in detail.
Thank you for your response. I would like to be able to call (getData) query when the page loads and show the (getData) query results in a(using 'line method' -- see javascript code) line chart. When I use the data filters in javascript(categoryPicker), I would like to control filters (categoryPicker), to use (getData2) method query to filter the line charts' output. for example: when page loads, call query1(select top 100 * from data), then click/mouseover/search on filter(categoryPicker), filter the line chart results using qyery2(select * from data). I hope the explanation above clarifies my problem. Any help would be very much appreciated. Thank you for your time and help.