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

Dynamically calculate cell values

1 Answer 235 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dirk LX
Top achievements
Rank 1
Dirk LX asked on 20 Jan 2010, 11:23 AM
Dear everybody,

my request is it to dynamically calculate cell values.

I feed my RadGridView with a dataset or datareader. I am looking for an event which gets fired while data is bounded. The method shall allow me to modify the current cell value based on a calculation of other cells. Something similar like excel also provides with the formula stuff.

Is there any way you can help me?

I also tried events like cellvaluechanged, cellvalidation,valuechanging and the other stuff.

Thanks for a quick reply.

best,

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 22 Jan 2010, 04:58 PM
Hi Dirk LX,

Thank you for the question.

You have two options to implement dynamically calculated values: Using Calculated Columns (Column Expressions) or using CellFormatting event. You can find a working sample of how to use expressions in our Examples application under Grid View >> Columns >> Expressions. You can change the cell value in CellFormatting event as it is shown in the following code snippet:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ColumnIndex == 6)
    {
        e.CellElement.Text = (Convert.ToInt32(e.CellElement.Text) + 1000).ToString();
    }
}

Do not hesitate to contact me again if you have any other questions.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Dirk LX
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or