private void BindCourseTitle(string year, string semester, string dept)
        {
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("select distinct courseTitle from marksInfo where stdYear='" + year + "' and stdSemester='" + semester + "' and stdDepartment='" + dept + "'", con);
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);

                if (dt.Rows.Count != 0)
                {
                    DropDownListForCourseTitle.DataSource     = dt;
                    DropDownListForCourseTitle.DataTextField  = "courseTitle";
                    DropDownListForCourseTitle.DataValueField = "courseTitle";
                    DropDownListForCourseTitle.DataBind();
                    DropDownListForCourseTitle.Items.Insert(0, new ListItem("Select Course Title...", "0"));
                }
                else
                {
                    DropDownListForCourseTitle.Items.Clear();
                    DropDownListForCourseTitle.Items.Add("Data Doesn't match");
                }
            }
        }
Beispiel #2
0
        private void BindCourseTitle()
        {
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("select distinct courseTitle from marksInfo where teacherEmail='" + Session["TEACHEREMAIL"].ToString() + "'", con);
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                sda.Fill(dt);

                if (dt.Rows.Count != 0)
                {
                    DropDownListForCourseTitle.DataSource     = dt;
                    DropDownListForCourseTitle.DataTextField  = "courseTitle";
                    DropDownListForCourseTitle.DataValueField = "courseTitle";
                    DropDownListForCourseTitle.DataBind();
                    DropDownListForCourseTitle.Items.Insert(0, new ListItem("Select Course Title...", "0"));
                }
            }
        }