It isn't too clear from your question what problem you are having - I assume that English is not your native language? So, I will have to make some assumptions:
1) You have a GridView, which displays two or more columns.
2) One of these is a Checkbox, called "CheckBox1", and the user (or your code) checks some CheckBoxes, and not others.
3) If a CheckBox is checked, include the value of the Rate column (Column 1, or the second column in the GridView) in a running total.
If this is correct, then:
int totalRate = 0;
for (int i = 0; i < GridView2.Rows.Count; i++)
{
GridViewRow row = GridView2.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("CheckBox1")).Checked;
if (isChecked)
{
totalRate += int.Parse(GridView2.Rows[i].Cells[1].Text);
}
}
Response.Write(totalRate.ToString());
You may need to change the
int
to another data type - if so do not forget to change in in both places!
If this is not correct, then what are you trying to do?