Getting Current Row Values in the DataGrid control

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 18
Reputation: mikefitz is an unknown quantity at this point 
Solved Threads: 0
mikefitz mikefitz is offline Offline
Newbie Poster

Getting Current Row Values in the DataGrid control

 
0
  #1
Aug 14th, 2006
Hi,
I'm using the DataGrid control with databound columns. I have an EditCommandColumn to allow for the Edit of the row. I'm having trouble retrieving the values of the row being edited in the UpdateCommand event.

For example e.Item.Cells(4).Text and DataGrid1.Items(lCurrRow).Cells(4).Text always returns a blank value instead of the value in the cell.

Does anyone know how to access the cell values from the row being updated a DataGrid control from the UpdateCommand event?

The command: DirectCast(e.Item.FindControl("txtBox1", TextBox).Text works fine for retrieving TemplateColumn type columns, but not databound columns.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 18
Reputation: mikefitz is an unknown quantity at this point 
Solved Threads: 0
mikefitz mikefitz is offline Offline
Newbie Poster

Re: Getting Current Row Values in the DataGrid control

 
0
  #2
Aug 16th, 2006
The following code worked to retrieve the cell value from the row currently being edited (DataGrid1.EditItemIndex = e.Item.ItemIndex)

Dim obj As Object = e.Item.Cells(1).Controls(0)
sCellValue = DirectCast(obj, TextBox).Text



Originally Posted by mikefitz
Hi,
I'm using the DataGrid control with databound columns. I have an EditCommandColumn to allow for the Edit of the row. I'm having trouble retrieving the values of the row being edited in the UpdateCommand event.

For example e.Item.Cells(4).Text and DataGrid1.Items(lCurrRow).Cells(4).Text always returns a blank value instead of the value in the cell.

Does anyone know how to access the cell values from the row being updated a DataGrid control from the UpdateCommand event?

The command: DirectCast(e.Item.FindControl("txtBox1", TextBox).Text works fine for retrieving TemplateColumn type columns, but not databound columns.

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC