Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144386 | May 3,2019 01:39 PM UTC | May 7,2019 01:42 PM UTC | ASP.NET Web Forms | 3 |
![]() |
Tags: Chart |
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bindChartData();
}
else
{
//other configurations here
this.Chart1.DataSource = data;
this.Chart1.DataBind();
}
}
private void bindChartData()
{
Series series1 = new Series();
Series series2 = new Series();
List<ChartSqlData> data = new List<ChartSqlData>();
string connectionString = null;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet dataset = new DataSet();
connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=false;Connect Timeout=100;";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string command2 = "SELECT * FROM [Products] WHERE UnitPrice < 10";
SqlCommand cmd1 = new SqlCommand(command2, con);
adapter.SelectCommand = cmd1;
adapter.Fill(dataset);
for (var i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
string x1 = Convert.ToString(dataset.Tables[0].Rows[i]["ProductName"]);
double y1 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitPrice"]);
double y2 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitsInStock"]);
data.Add(new ChartSqlData(x1, y1, y2));
}
this.Chart1.DataSource = data;
this.Chart1.DataBind();
}
protected void TradesDropDown_ValueSelect(object sender, Syncfusion.JavaScript.Web.DropdownListEventArgs e)
{
Session["ShipCity"] = e.Value;
} |
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bindChartData();
}
}
protected void TradesDropDown_ValueSelect(object sender, Syncfusion.JavaScript.Web.DropdownListEventArgs e)
{
Session["UnitPrice"] = e.Value;
string selected = Session["UnitPrice"].ToString();
//other configurations here
string command2 = "SELECT * FROM [Products] WHERE UnitPrice <" + " " + selected;
SqlCommand cmd1 = new SqlCommand(command2, con);
adapter.SelectCommand = cmd1;
adapter.Fill(dataset);
for (var i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
string x1 = Convert.ToString(dataset.Tables[0].Rows[i]["ProductName"]);
double y1 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitPrice"]);
double y2 = Convert.ToDouble(dataset.Tables[0].Rows[i]["UnitsInStock"]);
data.Add(new ChartSqlData(x1, y1, y2));
}
this.Chart1.DataSource = data;
this.Chart1.DataBind();
//other configurations here
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.