Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Getting edited value from ASP.NET DatGrid

I have a datagrid on an ASP.NET page. When i edit a column and attempt
to get the edited value to write to a database, i can only see the
original value. Here is the code (in .aspx.vb) i am using to get the
textbox value.           

Dim newData As String
Dim aTextBox As TextBox = CType(e.Item.Cells(I).Controls(0), TextBox)
newData = aTextBox.Text

Please help, I have looked everywhere for an answer and have found
nothing! How can i get the new  value?

Randy
Thursday, November 21, 2002

Which event are you doing that in?

Any chance that you're reloading the DataGrid before you look for the changed values? Perhaps by executing a DataBind() in the Load event even on PostBack?

Mike Gunderloy
Thursday, November 21, 2002

I don't know how it works with ASP.NET, but with Winforms this problem is solved by going through the CurrencyManager associated with the datagrid.

Joe Blandy
Thursday, November 21, 2002

Are you binding the datasource at each postback?
Perhaps you have something like:

DataGrid1.DataSource = thedataset
DataGrid1.DataBind()

in Page_Load and you are not checking for IsPostBack. Then, you are overwriting the new value with the old one.
Enclose it with if(!IsPostBack)

Hope it helps

Sergio Acosta
Friday, November 22, 2002

*  Recent Topics

*  Fog Creek Home