I assume this method is the one you are going to want to look at
UpdatetblCartItems(Session("CartID"),Quantity,intP roductID,ts)
It is here, again I assume, that you are writing values to a database which in turn is bound to the datagrid, am I correct?
If so, it seems that when that method is called, you simply fire a SQL INSERT statement (or stored procedure) that adds the item information to the table. To solve your problem, you could approach it 2 different ways, IMHO, and they are as follows:
1)You could run a SELECT count([value]) from shoppingcart where pID = [productID to add] then ExecuteScalar() to return the value. If the value returned is 0 you know that you then need to insert a new row but if n > 0 then you know that you need to call an update statement.
2)You could write a stored procedure that handled this logic for you and the decision to update or insert would be made in SQL Server and not in your code.
Personally, I would use the second option because it cuts out an additional round trip to SQL while still providing the same functionality. hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========