You need to make the update inside the loop, and then actually perform the update with the item code, quantity/price from the grid. Like:
foreach (GridViewRow gr in grvList.Rows)
{
objItemMaster.ItemCode = ((Label)gr.FindControl("txtItemCode")).Text;
objItemMaster.CurrentQuantity = Convert.ToDecimal(((TextBox)gr.FindControl("txtUnit")).Text);
objItemMaster.WholesalePrice = Convert.ToDecimal(((TextBox)gr.FindControl("txtPrice")).Text);
objItemMaster.ModifiedBy = Session["admin"].ToString();
objItemMaster.ModifiedDate = DateTime.Now;
objItemDb.UpdateItem(objItemMaster.ItemCode, objItemMaster.CurrentQuantity, objItemMaster.WholesalePrice);
}
Where the update item function is something like:
public bool UpdateItem(string itemCode, decimal quantity, decimal price)
{
try
{
strSql = "EXEC UpdateItem '" + PID + "', " + quantity + ", " + price;
return objDB.ExecuteNonQuerySQL(strSql);
}
catch (Exception ex)`enter code here`
{
objDB.LogError(ex.ToString());
return false;
}
}
That should make it work :)