Update Multiple Datagrid Rows

Update Multiple Datagrid Rows

am 08.04.2008 22:03:29 von Erik Lautier

I'm using an imagebutton in the datagrid footer to update a column of
textboxes in a "quantity" column with new values that the user
inputs. I'm using a datatable, which I then bind the datagrid to.
I've got the basic premise - dim a textbox, loop through the
datatable, find the "Quantity" control, set the values to those of the
textbox in the templatecolumn - but I haven't been able to get this to
work at all after several hours now. I've gone through tutorials but
nothing seems to do it...anyone have a code snippet to share? Thanks
in advance.

Re: Update Multiple Datagrid Rows

am 08.04.2008 23:50:10 von Erik Lautier

By the way, here's the code I'm using that fails; it produces a
"Object reference not set to an instance of an object." error at the
line I've marked with several asterisks. For some reason, quantityBox
is not being recognized.

Dim quantityCell As TableCell = e.Item.Cells(3)
Dim quantityBox As TextBox =
CType(quantityCell.FindControl("Quantity"), TextBox)
*****Dim quantity As Integer = System.Int32.Parse(quantityBox.Text)
Dim i as integer
for i = 0 to ObjDT.rows.count -1
objDT.rows(i).item("Quantity") = quantity
next


On Apr 8, 4:03 pm, Erik Lautier wrote:
> I'm using an imagebutton in the datagrid footer to update a column of
> textboxes in a "quantity" column with new values that the user
> inputs. I'm using a datatable, which I then bind the datagrid to.
> I've got the basic premise - dim a textbox, loop through the
> datatable, find the "Quantity" control, set the values to those of the
> textbox in the templatecolumn - but I haven't been able to get this to
> work at all after several hours now. I've gone through tutorials but
> nothing seems to do it...anyone have a code snippet to share? Thanks
> in advance.