DataTable Updating

Results 1 to 2 of 2

Thread: DataTable Updating

  1. #1
    Join Date
    Dec 1969

    Default DataTable Updating

    I have am trying to update quantity value in a datatable bound to a datagrid that I am using as a shopping cart. I want to be able to update the quantity of an item in the shopping cart by entering the new value into the text box, and then clicking on an update button that takes the values from the text boxes and updates the datatable values for each item.<BR><BR>In the datagrid I have the following line of code for the textbox that holds the quantity value.<BR><BR>&#060;asp:textbox id="txtQuantity" Width="30" Text=&#039;&#060;%#Container.DataItem("Quantity")% &#062;&#039; runat="server"/&#062; <BR><BR>In the code behind, I use the following line of code in the function that makes the datatable for the quantity value:<BR><BR>objDT.Columns.Add("Quantity", GetType(String)) <BR><BR>I have tried the following code for updating but it fails to work:<BR><BR>Sub btnUpdate (sender as System.Object, e as System.EventArgs ) <BR>&#039; Update the cart contents for an item, quantity and if delete check box checked remove item <BR>objDT = Session("Cart") <BR>Dim dgItem as DataGridItem <BR><BR>For Each objDR In objDT.Rows <BR>objDR("Quantity") = CType(dgItem.FindControl("txtQuantity"), TextBox).Text <BR>Next <BR><BR>dg.DataSource =objDT <BR>dg.DataBind() <BR>Session("Cart") = objDT <BR>End Sub<BR><BR>Any help or suggestions on this would be great.<BR><BR>Gillies

  2. #2
    Join Date
    Dec 1969

    Default RE: DataTable Updating

    Check out this article, it&#039;s pretty much everything you ever wanted to know about the datagrid but where afraid to ask.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts