protected void ddlInterest3_SelectedIndexChanged(object sender, EventArgs e) { string ActivityID = DetailsView1.DataKey.Value.ToString(); string interest3 = "SELECT VolunteerInterests.V_ID, V_Name, V_LastName, V_MobileNo1,V_MobileNo2, V_Email from VolunteerInterests, Volunteer WHERE VolunteerInterests.V_ID = Volunteer.V_ID AND Interests_ID = " + ddlInterest3.SelectedValue + " AND VolunteerInterests.V_ID NOT IN (SELECT VolunteerJoinActivities.V_ID FROM VolunteerJoinActivities WHERE Activity_ID = " + ActivityID + ");"; DataTable dtInterest3 = dbconn.QueryExecuteScalar(interest3); GridviewInterest3.DataSource = dtInterest3; GridviewInterest3.DataBind(); lblInterest3.Text = GridviewInterest3.Rows.Count.ToString(); dbconn.Close(); }
protected void SaveInterest3_Click(object sender, EventArgs e) { CheckBox chkbox = new CheckBox(); foreach (GridViewRow grdRow in GridviewInterest3.Rows) { chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("chk")), typeof(CheckBox)); if (chkbox.Checked) { string keyID = (string)GridviewInterest3.DataKeys[grdRow.RowIndex].Value.ToString(); string sqlSelectVolunteer = "Insert into VolunteerJoinActivities(V_ID,VJA_Status,Activity_ID) Values (" + keyID + ",'Selected'," + DetailsView1.SelectedValue + ") ;"; dbconn.QueryExecuteScalar(sqlSelectVolunteer); } } GridviewInterest3.DataBind(); dbconn.Close(); }