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

setting default value on New insert row basing on the value of previous row

1 Answer 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tai
Top achievements
Rank 1
Tai asked on 09 Sep 2010, 04:45 AM
Hi
Is it possible to set the default value of the next empty cell on the new row basing on the value of the previous value of the same column?
For example, assuming we have a radgridview with 2 column Reference , Amount and some available data
Reference  Amount
ABC            100
BCD             200

after pressing 'insert' , it will appear an empty row with default value of Reference will be "BCD" (the value of the previous cell in the same column)


thank you

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 09 Sep 2010, 06:34 AM
Hi Tai,

Yes, this is possible. You need to subscribe to the AddingNewDataItem event of the grid and initialize your business object the way you need:

private void clubsGrid_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
    e.NewObject = new Club()
    {
        Name = (this.clubsGrid.Items[this.clubsGrid.Items.Count - 1] as Club).Name
    };
}

Hope this will get you started.

Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Tai
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or