Calculated Column Value Issue

2 posts, 0 answers
  1. Guy
    Guy avatar
    60 posts
    Member since:
    Sep 2010

    Posted 06 Oct 2011 Link to this post

    Hi All,

    I'm having a strange problem which I can't seem to work out the reason for. I have a series of columns of which one is calculated. When I go to save the values (be it a new row or an update), the field which the calculated column is linked with does not get updated.

    My code for creating the calculated column is as follows:

    GridViewDecimalColumn col = new GridViewDecimalColumn();
                col.Name = "Total";
                col.HeaderText = "Total";
                col.FormatString = "{0:c0}";
                col.MaxWidth = 90;
                col.MinWidth = 90;
                col.Width = 90;
                col.FieldName = "Total";
                col.FormatInfo = CultureInfo.CreateSpecificCulture("en-GB");
                radGridView1.Columns["Total"].Expression = "IsNull(Ink, 0) + IsNull(PB_Products, 0) + IsNull(Office_Supplies, 0) + IsNull(Freight, 0)";
                radGridView1.Columns.Move(11, 9);

    For the Save Button, I'm using TableAdapter.Update()

    Where abouts have I gone wrong?



  2. Alexander
    Alexander avatar
    306 posts

    Posted 10 Oct 2011 Link to this post

    Hello Guy,

    Thank you for your question.

    A calculated RadGridView column cannot be bound to a data source (even by defining its FieldName property). This column receives the values of its cells from the calculations of its Expression. You should implement your own logic to read the values from the calculated column and write them in the data source.

    I hope it helps. Please write back if you have additional questions.

    Best regards,
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top