Al Pascual



Geo RSS
Geo Twitter Timeline

Blogs I read

<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Code Snip: Getting the values on GridView update event

Microsoft should call it a bug, when using the GridView updating event the arguments received by the method are empty.

If you have been using the GridView and to update the value, you'll find that after pressing the update button no values come into the event. To resolve this issue, you'll have to run this on the Updating event from the GridView:

// This to populate the NewValues with the data
       GridView gv = (GridView)sender;

       for (int i = 0; i < GridViewInput.Columns.Count; i++)
       {
           DataControlFieldCell cell = gv.Rows[e.RowIndex].Cells[i] as DataControlFieldCell;
           gv.Columns[i].ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit, true);
       }

Hope this helps

Cheers

Al

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# November 28, 2007 11:36 AM

bharath said:

it not working
# December 18, 2007 2:09 AM

satish said:

I need entire code to update the grid view with events in .NET 2.0,please send me at babu_dpl@yahoo.com

# December 18, 2007 6:17 AM

mahesh said:

Can you give Code behind for Edit,Update,Cancle in Gridview.
# January 14, 2008 6:00 AM

sophie said:

Can you please provide the code behind for the gridview edit, update and cancel events? Thanks!
# April 11, 2008 12:33 PM

e said:

Could you please explain further? I've added the code to my gridview_RowUpdating method but I still get the old values. Heres the method: public void GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e) { // This to populate the NewValues with the data GridView gv = (GridView)sender; for (int i = 0; i
# April 30, 2008 7:10 AM

Sandeep said:

Hi can you send me the complete code at vinjamuri3@gmail.com
# June 2, 2008 3:37 PM

pavan dwivedi said:

its not working properly

# June 28, 2008 1:17 AM