protected void Button1_Click(object sender, EventArgs e) { foreach (GridViewRow gvrow in GridView1.Rows) { string sid = gvrow.Cells[0].Text; RadioButtonList rbAtt = (RadioButtonList)GridView1.Rows[selectedIndex].FindControl("rbAtt"); con.Open(); SqlCommand cmd = new SqlCommand("InsertAttendence", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@StudentId", sid); if (dlAtt.SelectedItem.Text=="Morning") { cmd.Parameters.AddWithValue("@Morning", rbAtt.SelectedValue); } else { cmd.Parameters.AddWithValue("@Morning", DBNull.Value); } if (dlAtt.SelectedItem.Text=="Evening") { cmd.Parameters.AddWithValue("@Evening", rbAtt.SelectedValue); } else { cmd.Parameters.AddWithValue("@Evening", DBNull.Value); } cmd.ExecuteNonQuery(); con.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)