سلام من برای ثبت نام در دوره ها یک کدی نوشتم که وقتی کاربر دوره هایی رو تیک میزنه و بعد روی دکمه ثبت نام کلیک میکنه این دوره ها واسش ثبت میشه.ولی مشکل اینه که فقط بالاترین دوره واسش ثبت میشه و دیگه دوره های پایینی ثبت نمیشن.کدم رو میذارم دوستان بگن چرا؟



int a = GridView1.Rows.Count;
int i;
for (i = 0; i < a; i++)
{
try
{
if (((CheckBox)GridView1.Rows[i].FindControl("chk")).Checked == true)
{

SqlConnection con = new SqlConnection(connectionstring.connectionString);
SqlCommand Cmd = new SqlCommand("userdore", con);
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.AddWithValue("@DoreId", GridView1.Rows[i].Cells[0].Text);
Cmd.Parameters.AddWithValue("@UserId",Session["username"]);
con.Open();
Cmd.ExecuteNonQuery();
con.Close();

GridView1.DataBind();
GridView2.DataBind();

}
else { }
}
catch { }

}