this is in c# vs2003, web forms
i have this dgv and which is populated by some database values i have one column called price and i want to get the total of that column to a local veriable can some one tell me how to do it
@kalpa23,
are u changing the values in the grid..?
or, if you are just populating the data in a grid (i.e if it is not editable, just add a column in ur SP that you are calling, SUM([Amount]) from Table.
if(dtDisp_changed.Rows.Count > 0)
{
for (int i = 0; i < dtDisp_changed.Rows.Count; i++)
{
if(i == 0)
sum = Convert.ToDecimal(dtDisp_changed.Rows[0]["AMT"]);
if(i>0)
sum = sum + Convert.ToDecimal(dtDisp_changed.Rows[i]["AMT"]);
}
}
MessageBox.Show(Convert.ToString(sum));
where,
dtDisp_changed is the DataTable,
["AMT"] is the column that you want the addition to be done....