Karthik K

Karthik K

  • 1k
  • 745
  • 193.7k

Adding Cart in the Grid ?..

Nov 13 2017 5:04 AM
Hi All,
 
I want to add the additional qty on my Dishcart of grid. Whenever I am clicking the addup button ., it should be Incremented by 1. How can do it. Can anyone guide me? Thanking you 
 
 
Sample code : 
 
protected void grdCart_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Qty")
{
for (int i = 0; i < grdCart.Rows.Count; i++)
{
TextBox Tb = (TextBox)grdCart.Rows[i].FindControl("txtEditCount");
QtyCount = Convert.ToInt32(Tb.Text);
QtyCount += 1;
DishCart_DataTable.Rows[i]["Count"] = QtyCount;
DishCart_DataTable.Rows[i]["Total"] = QtyCount * Convert.ToDecimal(DishCart_DataTable.Rows[i]["Price"]);
// Loading Grid..
grdCart.DataSource = DishCart_DataTable;
grdCart.DataBind();
}
}
}
 
This code has some issue. when click the add up button its added but when I select some other dish. Already selected items getting incremented by that should not happen. I Want to update the qty on the particular row on in grid.