Databinding for Webform - Newbie question

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Databinding for Webform - Newbie question

Post by pw » Fri Jan 27, 2006 5:48 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jan 27, 2006 10:24 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Post by pw » Sun Jan 29, 2006 10:37 pm

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Jan 30, 2006 10:30 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Post by pw » Mon Jan 30, 2006 10:09 pm

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).

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 31, 2006 9:43 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Post by pw » Sun Feb 05, 2006 11:38 pm

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.

LordWhorfin
Newbie
Newbie
Posts: 24
Joined: Wed Feb 22, 2006 12:00 am
Location: Flagstaff, Arizona, USA

Post by LordWhorfin » Thu Mar 23, 2006 8:47 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 24, 2006 10:20 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply