Hi i have 3 list view...1=Courses, 2=Semester, 3= Section..
when i select any course so in semesterlist view semester should come with respect to Corses...similary when i select semester so section should come with respect to semester...but i m not able to do it......
i have written this code...

private void Teacher_Login_Load(object sender, EventArgs e)
        {
            MyConnection = new SqlConnection("Data Source=.;Initial Catalog=Bahria_Managment;Integrated Security=True");

            MyDataAdapter = new SqlDataAdapter("select distinct(c.C_Name) from tblCourses c, tblSession s where c.C_Code=s.C_Code and  s.T_Id = '" + Login.sUserName + "'", MyConnection);
            MyDataSet = new DataSet();
            MyDataAdapter.Fill(MyDataSet);

            for (int i = 0; i < MyDataSet.Tables[0].Rows.Count; i++)
            {
                string C_Name = MyDataSet.Tables[0].Rows[i].ItemArray[0].ToString();
                listviewTCourse.Items.Add(C_Name);
            }

        }

        private void listviewTCourse_SelectedIndexChanged(object sender, EventArgs e)
        {
            MyDataAdapter = new SqlDataAdapter("select distinct(s.Semester_No) from tblSession s,tblCourses c where s.C_Code=c.C_Code  and  c.C_Name = '" + listviewTCourse.SelectedItems + "'", MyConnection);
            MyDataSet = new DataSet();
            MyDataAdapter.Fill(MyDataSet);

            for (int i = 0; i < MyDataSet.Tables[0].Rows.Count; i++)
            {
                string SemNo = MyDataSet.Tables[0].Rows[i].ItemArray[0].ToString();
                listviewSem.Items.Add(SemNo);
            }

i hope some will will help me...
Regards..
Farhad..

Change to:

private void listviewTCourse_SelectedIndexChanged(object sender, EventArgs e)
        {
            MyDataAdapter = new SqlDataAdapter("select distinct(s.Semester_No) from tblSession s,tblCourses c where s.C_Code = c.C_Code  and  c.C_Name = '" + listviewTCourse.SelectedItem.ToString() + "'", MyConnection);
            MyDataSet = new DataSet();
            MyDataAdapter.Fill(MyDataSet);

            foreach(DataRow dr in MyDataSet.Tables[0].Rows)
            {
                 listViewSem.Items.Add(dr[0].Tostring());
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.