1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| protected void Checked_Changed(object sender, EventArgs e)
{
CheckBox check;
Label lblResult, nbre1, nbre2;
foreach (GridViewRow r in GridView1.Rows)
{
check = (CheckBox)r.FindControl("check");
lblResult = (Label)r.FindControl("lblResult");
nbre1 = (Label)r.FindControl("nbre1");
nbre2 = (Label)r.FindControl("nbre2");
if (check.Checked)
{
int nb1 = int.Parse(nbre1.Text);
int nb2 = int.Parse(nbre2.Text);
int result = nb1 + nb2;
lblResult.Text = result.ToString();
}
else
lblResult.Text = "";
}
} |