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

Access Edit Item in SqlDataSource Updating Event

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Waylon Campbell
Top achievements
Rank 1
Waylon Campbell asked on 08 Jul 2010, 04:34 PM
I need to access the item that is being edited from the updating event of a SqlDataSource.  Currently, I am able to access the item by using the following code.

protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
    foreach (GridItem item in rgvResult.MasterTableView.Items)
    {
        if (item.Edit)
        {
            GridEditFormItem editItem = (GridEditFormItem)rgvResult.MasterTableView.GetItems(GridItemType.EditFormItem)[item.ItemIndex];
 
            //do stuff
        }
    }
}

Is there a method similar to GetInsertItem() that I can use to get the edited item or do I have to loop through the collection to get the item?

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 12 Jul 2010, 12:33 PM
Hello Waylon,

To access the RadGrid's item which is being edited,  you could try using the following code snippet:
protected void SessionDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
        int index = RadGrid1.EditItems[0].ItemIndex;
        GridEditFormItem editItem = RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[index] as GridEditFormItem;
 
        //do stuff
}

I hope this helps.

Regards,
Radoslav
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
0
Waylon Campbell
Top achievements
Rank 1
answered on 12 Jul 2010, 06:23 PM
Thanks, that does what I need.
Tags
Grid
Asked by
Waylon Campbell
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Waylon Campbell
Top achievements
Rank 1
Share this question
or