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

Modify some fields directly after the "Add new item"

1 Answer 16 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 07 Sep 2010, 01:07 PM
Hi!

I've a RadGridView, I wish to set some field to a default value when I create it.

I can't find the good event for this. 

Example:

I click on the Add new item of the RadGridView
An event intercept this action
--> I change some field
Life continue ;)

I'm sure this is made very easily but I can't find how :(

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 07 Sep 2010, 01:14 PM
Hi Julien,

The proper event is AddingNewDataItem.

There you can initialize the needed properties of your business object. Here is a sample:

private void clubsGrid_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
    e.NewObject = new Club()
    {
        Name = "initial name",
        Established = DateTime.Now.Date
    };
}

Hope this helps.

Kind regards,
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
Julien
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or