Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
520
Add Series dynamically
posted

The infragistics website contains an example that shows how to hide a series. While Hiding a series is easy, i want to dynamically add Series based on the values of a Webdropdown i parse into a list.

The following code is used to add a series, based on a date range and a multiselect dropdown:

DataTable datatable = new DataTable();
int i;
DataTable dt = new DataTable("TestTabel");
dt.Columns.Add("Machine", typeof(string));

for (i = 0; i < WebDropDown1.SelectedItems.Count; i++)
{
dt.Rows.Add(WebDropDown1.SelectedItems[i].Value.ToString());
}
string cs = string.Empty;

cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(cs);

con.Open();
SqlCommand cmd = new SqlCommand("FPYMaschineTabelle", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter tblvaluetype = cmd.Parameters.AddWithValue("@List", dt); //Passing table value parameter
SqlParameter Beginn = cmd.Parameters.AddWithValue("Beginn", WebDatePicker1.Value);
SqlParameter Ende = cmd.Parameters.AddWithValue("End", WebDatePicker2.Value);
tblvaluetype.SqlDbType = SqlDbType.Structured; // This is used to tell ADO.NET we are passing Table value Parameter

SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable SeriesTable = ds.Tables[0];


NumericSeries Series = new NumericSeries();
Series.Data.DataSource = SeriesTable;
Series.Data.LabelColumn = "Date";
Series.Data.ValueColumn = "FPY";
Series.DataBind();
UltraChart1.Series.Add(Series);

UltraChart1.Data.DataBind();
UltraChart1.Axis.X.Extent = 110;

con.Close();

How can I add a new series with the value column as the string for the stringlist and label column as date ? 

Parents Reply Children
No Data