Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi, I want to bind asp.net chart with some variable values.
the given below code contains some variable, I want to bind those values with my chart and display as given below.

Code:

C#
protected void btnSubmit_Click(object sender, EventArgs e)
{
    int cnt = Convert.ToInt32(txtCount.Text);
    DateTime start = Convert.ToDateTime(txtStart.Text);
    DateTime end = Convert.ToDateTime(txtEnd.Text);
    var date1 = start.ToShortDateString();
    var date2 = end.ToShortDateString();

    TimeSpan datedifference = end.Subtract(start);
    int dateCount = datedifference.Days;
    float maxUpload = dateCount * 288;  
    float remainingUpload = maxUpload - cnt;
    float averageUpload = remainingUpload / (dateCount * 288) * 100;
    float missdUpload = 100 - averageUpload;
    string siteid = ddlSiteID.SelectedValue;
}


ASP.NET
<asp:Chart ID="Chart1" runat="server">    
<Series>   
<asp:Series Name="Series1">   
</asp:Series>   
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">  </asp:ChartArea>  </ChartAreas>                                                          </asp:Chart>


http://stackoverflow.com/questions/30045471/how-to-bind-asp-net-chart[^]
[^]
Posted
Updated 4-May-15 23:26pm
v2
Comments
Sinisa Hajnal 5-May-15 3:54am    
Please correct the title, you have several type errors (1 in title) and it is confusing. Sorry, cannot help with charts, I could with chars :)

1 solution

You can build a datatable with your data and then bind it to chart.

See the examples in http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900