Problems with updating 1 row in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • foocc
    New Member
    • Feb 2007
    • 13

    Problems with updating 1 row in gridview

    Hi. I have a problem with gridview whereby when i want to update 1 row, other row changes as well.

    For example, i change the quantity in row 1 from 1 to 2, but when i click on update, other row's 'quantity' change to 2 as well. In the source code for this page, i add UpdateCommand=" UPDATE [Order_Details] SET [Quantity] = @Quantity" under <asp: SqlDataSource>

    Without UpdateCommand=" UPDATE [Order_Details] SET [Quantity] = @Quantity", this error will be shown when i click on 'update' button >>>
    Updating is not supported by data source 'SqlDataSourceS hoppingCart' unless UpdateCommand is specified.

    Please help...When i edit a row, i only want to update tht particular row and not every row in the gridview.

    Many thanks.
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Originally posted by foocc
    Hi. I have a problem with gridview whereby when i want to update 1 row, other row changes as well.

    For example, i change the quantity in row 1 from 1 to 2, but when i click on update, other row's 'quantity' change to 2 as well. In the source code for this page, i add UpdateCommand=" UPDATE [Order_Details] SET [Quantity] = @Quantity" under <asp: SqlDataSource>

    Without UpdateCommand=" UPDATE [Order_Details] SET [Quantity] = @Quantity", this error will be shown when i click on 'update' button >>>
    Updating is not supported by data source 'SqlDataSourceS hoppingCart' unless UpdateCommand is specified.

    Please help...When i edit a row, i only want to update tht particular row and not every row in the gridview.

    Many thanks.
    You should research SQL a little more and table structure.

    In order to update a single record your SQL has to specify that record using conditional WHERE clause.

    Code:
    UpdateCommand="UPDATE [Order_Details] SET [Quantity] = @Quantity WHERE QuantityID = " & RowQtyID & ""
    This is just an example of what you should have to update a single row.

    For more on using SQL go here
    W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      Hey, is this an ASP question or an ASP.NET question? Just asking because usually ASP developers don't use the phrase "gridview"

      Jared

      Comment

      Working...