We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Can't get data binding to work.

Thread ID:

Created:

Updated:

Platform:

Replies:

121100 Nov 10,2015 12:40 PM Nov 17,2015 03:57 AM ASP.NET Web Forms 3
loading
Tags: Chart
James Butler
Asked On November 10, 2015 12:40 PM

I am trying to use the data binding per the help file in Chart/Working with data but it isn't working.
I get this error message. 
Error 20 System.Collections.Generic.List`1[[Syncfusion.JavaScript.DataVisualization.Models.Series, Syncfusion.EJ, Version=13.3450.0.7, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89]] must have items of type 'Syncfusion.JavaScript.DataVisualization.Models.Series'. 'ej.Series' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.

 Below is my code:

ASPX file;
<ej:Chart ID="Chart1" runat="server" Width="485" Height="300" CanResize="true" OnClientSeriesRendering="seriesRender" 
        Depth="100" WallSize="2" Tilt="0" Rotation="34" PerspectiveAngle="90" EnableRotation="true" Enable3D="true">
           <CommonSeriesOptions Type="Column" />

            <Series>
                <ej.Series Name="2012" XName="Xvalue" YName="YValue1"></ej.Series>
            </Series>
        </ej:Chart>
-----------------------------------------------------------------------------------------------
CS code in page load;
try
        {
            connection.Open();

            SqlCommand command = DataAccess.GetSqlCommand(ref connection, commandText);

            command.CommandType = CommandType.Text;

            SqlDataAdapter adapter = DataAccess.GetSqlDataAdapter(ref command);

            DataSet data = new DataSet();
            int i = 0;
            adapter.Fill(data);

            

            List<ChartData> chartData = new List<ChartData>();

            for (i = 0; i <= data.Tables[0].Rows.Count - 1; i++)
            {
                

                chartData.Add(new ChartData("IAPD 2012",(decimal)data.Tables[0].Rows[i].ItemArray[0]));
                chartData.Add(new ChartData("IAPD 2013",(decimal)data.Tables[0].Rows[i].ItemArray[1]));
                chartData.Add(new ChartData("IAPD 2014",(decimal)data.Tables[0].Rows[i].ItemArray[2]));
                chartData.Add(new ChartData("IAPD 2015",(decimal)data.Tables[0].Rows[i].ItemArray[3]));
                chartData.Add(new ChartData("IAPD 2016",(decimal)data.Tables[0].Rows[i].ItemArray[4]));
                chartData.Add(new ChartData("IAPD 2017",(decimal)data.Tables[0].Rows[i].ItemArray[5]));
                chartData.Add(new ChartData("IAPD 2018",(decimal)data.Tables[0].Rows[i].ItemArray[6]));
                chartData.Add(new ChartData("IAPD 2019",(decimal)data.Tables[0].Rows[i].ItemArray[7]));
            }

            for (i = 0; i <= chartData.Count - 1; i++)
            {
                Debug.WriteLine(chartData[i].Xvalue + " - $" + chartData[i].YValue1);
            }

            adapter.Dispose();
            command.Dispose();
            connection.Close();

            this.Chart1.DataSource = chartData;
            this.Chart1.DataBind();
        }
        catch (Exception ex)
        {
            Debug.WriteLine("An error occured! " + ex.Message);
        }

public class ChartData
    {
        public ChartData(string xval, decimal yvalue1)
        {
            this.Xvalue = xval;
            this.YValue1 = yvalue1;
            
        }

        public string Xvalue
        {
            get;
            set;
        }

        public decimal YValue1
        {
            get;
            set;
        }
    } // end class ChartData


Sanjith Kesavan [Syncfusion]
Replied On November 11, 2015 02:26 AM

Hi James Butler,


Thanks for contacting Syncfusion support. We have analyzed your query and used the code example provided by you in our sample. We can able to reproduce the exact issue mentioned by you. While analyzing your code we found that inside the series tag you have used <ej.Series> for defining the series. Instead of that please use <ej:Series> for defining the series. Please find the following code example


[ASPX]



In the above code example we have done the suggested modification. Now the chart is rendering correctly.


We have modified the sample as per your requirement. Please find the sample from below mentioned location.

Sample Link: http://www.syncfusion.com/downloads/support/forum/121100/ze/Databinding2040171717

 

Please let us know if you have any concern.


Regards,

Sanjith K.



James Butler
Replied On November 16, 2015 11:16 AM

Thanks, I guess all I needed was an extra pair of eyes that could see the problem.
Those little things are the ones that really get you.


Sanjith Kesavan [Syncfusion]
Replied On November 17, 2015 03:57 AM

Hi James Butler,

 

We are glad that your issue has been resolved. Feel free to contact us any time if you face any other issues.

 

Thanks,

Sanjith K.


CONFIRMATION

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.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;