You should try a solution like this one:
assign ProductId
as name
to each input field
<input type="text" id="quantity" name="@row.ProductID" maxlength="2"
value="@row.quantity" style="width: 20px;" />
in if (IsPost)
scan input fields and update your table
if(IsPost){
foreach (string key in Request.Form){
db.Execute(@"UPDATE CartItems SET quantity = @0 WHERE CartID = @1 AND
ProductID = @2", Request.Form[key], basketowner, key);
}
}