Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Datatable from DataGrid

Status
Not open for further replies.

gi11ies

Programmer
Mar 26, 2002
52
I'm wondering if anyone has any tips on updating a value in a DataTable from a textbox in a DataGrid.

I have my text box value populated in the DataGrid using:

<itemtemplate>
<asp:textbox id="txtQuantity" Width="30" Text='<%#Container.DataItem("Quantity")%>' runat="server"/>
</itemtemplate>

I have a button that when pressed, I would like it to call a routine to update all the rows in the DataTable and DataGrid with the new values entered into the DataGrid, but just cant get it to work.

The Code I have been using, but it fails to work is as follows:

Sub btnUpdate (sender as System.Object, e as System.EventArgs )
objDT = Session("Cart")
Dim dgItem as DataGridItem
For Each objDR In objDT.Rows
objDR("Quantity") = dgItem.FindControl("txtQuantity")
Next

dg.DataBind()
objDT = dg.DataSource
Session("Cart") = objDT
End Sub

Any tips or suggestions on how to do this would be great.

Gillies
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top