Update Multiple Datagrid Rows

E

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.
 
E

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top