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
} |