Grid View Calculation
Create a table with following columns -
Now , we have to code for calculate button as when we Select the desired product enter the Quantity and click on calculate button, the respective amount of the product for no. of items will be shown in the total amount section and
the complete amount will be shown in the label .
Now,
CODE-
int qty, amt, tot, sum=0;
foreach(GridViewRow gr1 in GridView1.Rows)
{
CheckBox c1 = (CheckBox) gr1.FindControl("ck1");
TextBox tq = (TextBox) gr1.Findcontrol("txtq1");
TextBox ta = (TextBox) gr1.FindControl("txta1");
if(c1.Checked)
{
qty = int.Parse(tq.Text);
amt = int.Parse(gr1.Cells[2].Text);
tot = qty * amt;
sum = sum + tot;
ta.Text = tot.ToString();
}
}
Label1.Text = sum.Tostring();


Comments
Post a Comment