Datagrid problem :(

N

news.skynet.be

Hi;

I have the following code:

(...)

Sub MyDataGrid_Edit(sender As Object, e As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = e.Item.ItemIndex
BindGrid()
End Sub 'MyDataGrid_Edit


Sub MyDataGrid_Cancel(sender As Object, e As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = - 1
BindGrid()
End Sub 'MyDataGrid_Cancel


Sub MyDataGrid_Update(sender As Object, e As DataGridCommandEventArgs)
' For bound columns, the edited value is stored in a TextBox.
' The TextBox is the 0th element in the column's cell.
Dim qtyText As TextBox = CType(e.Item.Cells(2).Controls(0), TextBox)
Dim priceText As TextBox = CType(e.Item.Cells(3).Controls(0),
TextBox)

Dim item As String = e.Item.Cells(1).Text
Dim qty As String = qtyText.Text
Dim price As String = priceText.Text
End Sub

(...)


After clicking on the "Edit" link of my datagrid. The whole row goes in edit
mode. Each cell has a textbox.
I have filled in some data in each cell and press the update button...

The Update event is raised. But now I have a problem. The qtyText.Text and
priceText.Text are always empty !!!


Any idea what I do wrong?
 
M

Mark

Try
Dim qtyText As TextBox = CType(e.Item.Cells(2).Controls(1), TextBox)
Dim priceText As TextBox = CType(e.Item.Cells(3).Controls(1),
TextBox)

instead. Alternatively, put a Watch on e.Item.Cells(2) and drill down into
the controls to see which one you need. HTH.

-Mark
www.dovetaildatabases.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top