I am trying to get sum from datagridview to label or last row of datagridview Please help me Here is My code
public void total()
{
foreach (DataGridViewRow item in tbl_Purchase.Rows)
{
int n = item.Index;
int tPrice=0;
int tQuantity=0;
int tAmount=0
tPrice += (int.Parse(tbl_Purchase.Rows[n].Cells[3].Value.ToString()));
tQuantity += (int.Parse(tbl_Purchase.Rows[n].Cells[4].Value.ToString()));
tAmount += (int.Parse(tbl_Purchase.Rows[n].Cells[5].Value.ToString()));
l_Price.Text = (Convert.ToString(tPrice));
l_Quantity.Text = (Convert.ToString(tQuantity));
l_Amount.Text = (Convert.ToString(tAmount));
}
}
public void total()
{
var tPrice=0;
var tQuantity=0;
var tAmount=0
foreach (DataGridViewRow item in tbl_Purchase.Rows)
{
tPrice += (int.Parse(tbl_Purchase.Rows[item.Index].Cells[3].Value.ToString()));
tQuantity += (int.Parse(tbl_Purchase.Rows[item.Index].Cells[4].Value.ToString()));
tAmount += (int.Parse(tbl_Purchase.Rows[item.Index].Cells[5].Value.ToString()));
}
l_Price.Text = (Convert.ToString(tPrice));
l_Quantity.Text = (Convert.ToString(tQuantity));
l_Amount.Text = (Convert.ToString(tAmount));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.