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

A problem addNewRow

1 Answer 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tung
Top achievements
Rank 1
Tung asked on 11 Aug 2008, 05:33 AM
Dear Team!

I have a table ['Id', 'Num' , 'Price' 'Total'] where Total =  Num*Price,
The Total column is readonly, When i type a value in Num colunm or Price column in 'Click here add new a row', i want to set the value to Total's cell is Num*Price


How to do it?

Regards
Tung

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 12 Aug 2008, 10:06 AM
Hi Tung,

You can handle CellEndEdit event of RadGridView. Consider the following code snippet:

void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e) 
    if (this.radGridView1.CurrentRow is GridViewNewRowInfo && (e.ColumnIndex == 3 || e.ColumnIndex == 4)) //ColumnIndex 3 and 4 are for Num and Price columns 
    { 
        GridViewNewRowInfo newRowInfo = (GridViewNewRowInfo)this.radGridView1.CurrentRow; 
        newRowInfo.DataRowInfo.Cells["Total"].Value = newRowInfo.DataRowInfo.Cells["Num"].Value * newRowInfo.DataRowInfo.Cells["Price"].Value; 
    } 

Don't hesitate to contact us if you have other questions.

Greetings,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Tung
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or