protected void ddlArea_SelectedIndexChanged(object sender, EventArgs e) { string ActivityID = DetailsView1.DataKey.Value.ToString(); string Area1 = "SELECT VolunteerJoinedAreas.V_ID, V_Name, V_LastName, V_MobileNo1,V_MobileNo2, V_Email from VolunteerJoinedAreas, Volunteer WHERE VolunteerJoinedAreas.V_ID = Volunteer.V_ID AND JA_ID = " + ddlArea.SelectedValue + " AND VolunteerJoinedAreas.V_ID not in(SELECT VolunteerJoinActivities.V_ID FROM VolunteerJoinActivities WHERE Activity_ID = " + ActivityID + ");"; DataTable dtArea1 = dbconn.QueryExecuteScalar(Area1); GridViewArea1.DataSource = dtArea1; GridViewArea1.DataBind(); dbconn.Close(); int numRow = GridViewArea1.Rows.Count; lblArea1.Text = numRow.ToString(); }
protected void SaveArea2_Click(object sender, EventArgs e) { CheckBox chkbox = new CheckBox(); foreach (GridViewRow grdRow in GridViewArea1.Rows) { chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("chk")), typeof(CheckBox)); if (chkbox.Checked) { string keyID = (string)GridViewArea1.DataKeys[grdRow.RowIndex].Value.ToString(); string sqlSelectVolunteer = "Insert into VolunteerJoinActivities(V_ID,VJA_Status,Activity_ID) Values (" + keyID + ",'Selected'," + DetailsView1.SelectedValue + ") ;"; dbconn.QueryExecuteScalar(sqlSelectVolunteer); } } dbconn.Close(); GridViewArea1.DataBind(); }