コード例 #1
0
        protected void ddlInterest_SelectedIndexChanged(object sender, EventArgs e)
        {
            string    ActivityID  = DetailsView1.DataKey.Value.ToString();
            string    interest1   = "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 = " + ddlInterest.SelectedValue + " AND VolunteerInterests.V_ID NOT IN (SELECT VolunteerJoinActivities.V_ID FROM VolunteerJoinActivities WHERE Activity_ID = " + ActivityID + ") ;";
            DataTable dtInterest1 = dbconn.QueryExecuteScalar(interest1);

            GridviewInterest1.DataSource = dtInterest1;
            GridviewInterest1.DataBind();
            dbconn.Close();
            lblInterest.Text = GridviewInterest1.Rows.Count.ToString();
        }
コード例 #2
0
        protected void SaveInterest2_Click(object sender, EventArgs e)
        {
            CheckBox chkbox = new CheckBox();

            foreach (GridViewRow grdRow in GridviewInterest1.Rows)
            {
                chkbox = (CheckBox)Convert.ChangeType(((CheckBox)grdRow.FindControl("chk")), typeof(CheckBox));
                if (chkbox.Checked)
                {
                    string keyID = (string)GridviewInterest1.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();
            GridviewInterest1.DataBind();
        }