This is a migrated thread and some comments may be shown as answers.

Binding with a List<CustomObject> doesn't work - Why ?

1 Answer 45 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 22 Jun 2016, 08:25 AM

Hello,

I try to bind an HtmlChart with a Custom List<> of object, like so:

 

--------------------------- C#:

        protected void Page_Load(object sender, EventArgs e)
        {

            RadHtmlChart_LineSeries_Avec_Objet.DataSource = oGetData();
            RadHtmlChart_LineSeries_Avec_Objet.DataBind();

        }

        public class monObjet
        {
            int ID { get; set; }
            decimal ValuePumpA { get; set; }
            decimal ValuePumpB { get; set; }
            decimal ValuePumpC { get; set; }
            decimal ValuePumpD { get; set; }


            public monObjet(int id, decimal VPumpA, decimal VPumpB, decimal VPumpC, decimal VPumpD)
            {
                ID = id;
                ValuePumpA = VPumpA;
                ValuePumpB = VPumpB;
                ValuePumpC = VPumpC;
                ValuePumpD = VPumpD;
            }
        }

        public List<monObjet> oGetData()
        {
            List<monObjet> returnList = new List<monObjet>();
            for (int i = 0; i < 12; i++)
            {
                returnList.Add(new monObjet(i, i+1, i+2, i+3, i+4));
            }
            return returnList;
        }

}

 

--------------------------- ASPX:

               <telerik:RadHtmlChart runat="server" ID="RadHtmlChart_LineSeries_Avec_Objet" Width="1000px" Height="300px" ChartTitle-Text="HtmlChart sur List<objet>">
                    <PlotArea>
                        <Series>
                            <telerik:LineSeries Name="Pump A" DataFieldY="ValuePumpA" ColorField="Yellow" >
                                <LabelsAppearance Visible="false"/>
                            </telerik:LineSeries>


                            <telerik:LineSeries Name="Pump B" DataFieldY="ValuePumpB" ColorField="Green" >
                                <LabelsAppearance Visible="false"/>
                            </telerik:LineSeries>


                            <telerik:LineSeries Name="Pump C" DataFieldY="ValuePumpC" ColorField="Red" >
                                <LabelsAppearance Visible="false"/>
                            </telerik:LineSeries>


                            <telerik:LineSeries Name="Pump D" DataFieldY="ValuePumpD" ColorField="Black">
                                <LineAppearance LineStyle="Smooth" Width="3" />
                                <MarkersAppearance BackgroundColor="Red" MarkersType="Circle" Visible="true"/>
                                <LabelsAppearance Visible="false"></LabelsAppearance>
                            </telerik:LineSeries>
                        </Series>


                        <YAxis>
                            <LabelsAppearance DataFormatString="{0}"></LabelsAppearance>
                        </YAxis>


                        <XAxis>
                            <Items>
                                <telerik:AxisItem LabelText="January"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="Februrary"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="March"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="April"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="May"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="June"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="July"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="August"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="September"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="October"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="November"></telerik:AxisItem>
                                <telerik:AxisItem LabelText="December"></telerik:AxisItem>
                            </Items>
                        </XAxis>
                    </PlotArea>
                    <Legend>
                        <Appearance Visible="true"></Appearance>
                    </Legend>
                </telerik:RadHtmlChart>

 

But that doesn't work.

Why ?

Thanks for your suggestions

 

1 Answer, 1 is accepted

Sort by
0
Pierre
Top achievements
Rank 1
answered on 22 Jun 2016, 02:20 PM

Hello,

I have found my error : All the properties of my public object must be declared public...

I was thinking properties of an Public class was public, but no !

 

THANKS

 

 

 

Tags
Chart (HTML5)
Asked by
Pierre
Top achievements
Rank 1
Answers by
Pierre
Top achievements
Rank 1
Share this question
or