Page 1 of 1
Databinding for Webform - Newbie question
Posted: Fri Jan 27, 2006 5:48 am
by 6923298
Hi,
I'm new to Teechart, and I'm just wondering what is the best method to bind data from a SQL query to Webchart. What I did was to first insert a Dataset and added a connection string to the Dataset. Then to plot the data out, my code for the *.aspx.cs file is as follows:
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
DataSet1TableAdapters.TRADINGPRICETableAdapter adaptor = new DataSet1TableAdapters.TRADINGPRICETableAdapter();
DataSet1.TRADINGPRICEDataTable table = adaptor.GetData();
DataView view = table.DefaultView;
Steema.TeeChart.Chart Chart2 = WebChart1.Chart;
Chart2.Aspect.View3D = false;
Steema.TeeChart.Styles.Line series1 = new Steema.TeeChart.Styles.Line(Chart2);
series1.DataSource = view;
series1.XValues.DataMember = "date";
series1.YValues.DataMember = "price";
}
I'm using Visual Studio 2005. Thanks.
Posted: Fri Jan 27, 2006 10:24 am
by narcis
Hi dave,
I'd suggest you to follow what I told at
this other forum thread. You'll find the tutorials at TeeChart's program group.
Posted: Sun Jan 29, 2006 10:37 pm
by 6923298
Thanks Narcis.
I currently have Tee Chart 5 and evaluting Tee Chart .Net V2 Evaluation, so I don't have access to the BindingSource support on the Customer Download Area. Perhaps Steema might want to consider providing the support for evaluation users as well, since it's difficult for the users to purchase a evaluation copy if they can't evaluate it thoroughly.
With regards to your advice in the other thread (to bsindorf):
In Visual Studio 2005 you should try using BindingSource:
1) Go to Data tab and select "Show Data Sources".
2) Right-click on the Data Sources toolbox and select "Add New Data Source".
I'm using Visual Studio 2005 and there is no BindingSource selection in the Data toolbox (for Web Development) and there is also no "Add New Data Source" selection.
The tutorials and demos for webforms weren't very helpful, especially to show how to obtain data from the database. The data in the demos are populated by FillSampleValues, while the tutorial's explanation for webform connection to datasources is given as
You may connect Datasources via ASP.NET using a TeeChart WebChart on an ASP.NET WebForm in a manner virtually identical to that in which datasources can be connection to a TeeChart Component on a WinForm.
Do hope you can provide more detailed examples for webforms because the connection to datasource for webforms are not exactly the same as winform.
Thank you.
Posted: Mon Jan 30, 2006 10:30 am
by narcis
Hi dave,
I currently have Tee Chart 5 and evaluting Tee Chart .Net V2 Evaluation, so I don't have access to the BindingSource support on the Customer Download Area.
This update was included in one of the latest Debug Builds. For an evaluation version supporting that you'll have to wait until the next maintenance release is out.
Perhaps Steema might want to consider providing the support for evaluation users as well, since it's difficult for the users to purchase a evaluation copy if they can't evaluate it thoroughly.
We already offer support to the evaluation users at our public newsgroups ([url]news://
www.steema.net[/url]).
I'm using Visual Studio 2005 and there is no BindingSource selection in the Data toolbox (for Web Development) and there is also no "Add New Data Source" selection.
Sorry, my explanation may not be accurate enough. I meant to select "Show Data Sources" at the "Data" menu in VS2005. Once the "Data Sources" toolbox is visible, right-click on it and select "Add New Data Source".
Do hope you can provide more detailed examples for webforms because the connection to datasource for webforms are not exactly the same as winform.
This is because there's already a tutorial for that which is called
Tutorial8 - ADO.NET Database Access.
Posted: Mon Jan 30, 2006 10:09 pm
by 6923298
Hi Narcis,
Sorry, my explanation may not be accurate enough. I meant to select "Show Data Sources" at the "Data" menu in VS2005. Once the "Data Sources" toolbox is visible, right-click on it and select "Add New Data Source".
I believe the "Data" menu is only available for window applications, not for web sites (web forms, etc).
Posted: Tue Jan 31, 2006 9:43 am
by narcis
Hi dave,
There's no design-time support for databases in WebForms. It doesn't make much sense sending a dataset to a browser. This needs to be done at server side using any of the examples I mentioned before.
Posted: Sun Feb 05, 2006 11:38 pm
by 6923298
I want to share with others the approach I used to plot multiple series for webform:
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
string ConnString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
string sQuery = "select * from ABC";
SqlConnection myConnection = new SqlConnection(ConnString);
SqlCommand myCommand = new SqlCommand(sQuery, myConnection);
myConnection.Open();
Chart ch1 = WebChart1.Chart;
Series series1 = ch1.Series.Add(new Line());
Series series2 = ch1.Series.Add(new Line());
SqlDataReader myReader = myCommand.ExecuteReader();
int XColumn = myReader.GetOrdinal("XValues");
int YColumn = myReader.GetOrdinal("YValues");
while (myReader.Read())
{
if (myReader["FilterColumn"].ToString() == "A")
{
series1.Add(Convert.ToDateTime(myReader[XColumn]), Convert.ToDouble(myReader[YColumn]));
}
else if (myReader["FilterColumn"].ToString() == "B")
{
series2.Add(Convert.ToDateTime(myReader[XColumn]), Convert.ToDouble(myReader[YColumn]));
}
}
myReader.Close();
myConnection.Close();
}
The performance using this approach has been good.
Posted: Thu Mar 23, 2006 8:47 pm
by 9640386
narcis wrote:Hi dave,
There's no design-time support for databases in WebForms. It doesn't make much sense sending a dataset to a browser. This needs to be done at server side using any of the examples I mentioned before.
Can you explain how we create a server-side program to do this or point us to a tutorial? I'm new to Visual Studio and TeeChart, so I need the grand overview of how to gte data from my database into TeeChart and display that graphic on the web.
cheers, Paul
Posted: Fri Mar 24, 2006 10:20 am
by narcis
Hi Paul,
Ok, first of all I strongly suggest you to read the tutorials available at TeeChart's program group, specially:
Tutorial 1 - Getting Started
Tutorial 2 - Chart Display Properties
Tutorial 6 - Working with Series
Tutorial 8 - ADO.NET Database Access
Tutorial 9 - ASP.NET Applications
Tutorial 10 - Walk-through ASP Examples
Tutorial 17 - Designtime Runtime and License Requirements
Also, for what you request, to use datasource in VS2005 you could follow the BindingSource steps I told in
this thread.
You can also have a look at the ASP.NET example included with TeeChart's installation. If necessary, I can also try to arrange a WebForm example in VS2005 using BindingSource for you.