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

how to update grid items after update command button clicked

2 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Sep 2010, 04:47 PM
I have a radgrid using the automatic operations (insert/update/delete).  I have two columns in the grid called "ModifiedBy" and "DateCreated" When in edit mode and after the update button is clicked, I need to update the values of those columns for the selected item with the current logged in user and current date.  I know how to get the logged in user and date but I'm not clear on how to  bind that data back to the database.

How can this be done in the code-behind using vb.net?  I've tried to use e.Item.OwnerTableView.PerformUpdate() but I'm not sure how to do it.  Is there a better way to accomplish this?  Any help would be greatly appreciated.

 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Sep 2010, 09:01 AM
Hello Robert,

I guess you want to update the grid data item from an external button click. If that the case you can use FireCommandEvent method as described in the following documentation.

How to fire command events from code

Hope this helps,
Princy.
0
Ryan Eaves
Top achievements
Rank 1
answered on 17 Feb 2011, 01:51 AM
Princy, that isn't what he asked at all. The answer is to handle the OnUpdating or OnInserting events of your datasource and manipulate the values there. Like this:

protected void dsSomeEntity_Inserting(object sender, EntityDataSourceChangingEventArgs e)
{
    SomeEntity entity;
    entity = (SomeEntity)e.Entity;
 
    entity.DateCreated = DateTime.Now;
    entity.ModifiedBy = Session["UserId"];
 
}
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ryan Eaves
Top achievements
Rank 1
Share this question
or