radchart not binding properly on postback

Thread is closed for posting
3 posts, 0 answers
  1. Sagar
    Sagar avatar
    18 posts
    Member since:
    Dec 2011

    Posted 21 May 2013 Link to this post

    I have a rad chart which is throwing a java script error on a postback. here is the code:

    <telerik:RadHtmlChart Width ="400px" ChartTitle-Appearance-TextStyle-FontSize ="12px" Font-Size ="12px" Skin = "WebBlue"  ID = "chartReportsAll" runat ="server" Transitions ="true">
                            <telerik:ColumnSeries DataFieldY = "TotalAmount" Name = "Test" ></telerik:ColumnSeries>                
                        <XAxis DataLabelsField = "Name" Name = "test2">
                            <TitleAppearance Text="Campaign Name">
                                <TextStyle FontSize = "12px" />
                            <TitleAppearance Text="Amount Donated">
                                <TextStyle Margin="20" FontSize = "12px"/>

    And here is the code behind:

    chartReportsAll.DataSource = tb2

    The first time everything is fine. The chart shows correct data. I also have a button on this page which does a does a postback and some changes to the inputs of the graphs. After the postaback, i am getting a 

    Microsoft JScript runtime error: Expected ']'


    {var c=eval(this._dataSource); ( a dynamic page)

    and when i see the datasource it is showing as:

    [[{"TotalAmount":1000,"campaignID":2,"Name":"Annual Fund"},
    {"TotalAmount":300,"campaignID":3,"Name":"Library Fund"}]

    {"TotalAmount":1000,"campaignID":2,"Name":"Annual Fund"},
    {"TotalAmount":83,"campaignID":1,"Name":"Athletics Fund"},
    {"TotalAmount":300,"campaignID":3,"Name":"Library Fund"}]

    The first two lines is the data before the postback and the next 3 after the postback. So the problem here is the radchart is not clearing its datatsource. It is also remembering the prrevious one. Can any one please give me a solution ? Thanks.
  2. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 22 May 2013 Link to this post

    If you're setting the DataSource after every PostBack, you can safely disable the ViewState.  That should solve the issue you're having and give a small performance boost as well.

    chartReportsAll.EnableViewState = false;
  3. Sagar
    Sagar avatar
    18 posts
    Member since:
    Dec 2011

    Posted 23 May 2013 Link to this post

    Thanks worked.
Back to Top