Hi Guys

I have asp.net application there i have a dropdownlist , even if i select any item from that list
when going to debug mode i always get the first list item number and index but interface shows the selected item on it , what is the reason for it any idea ?

 SqlCommand cmd = new SqlCommand("update ClassSchedule set CourseID=@CourseID,[Day]=@Day,StartTime=@StartTime,EndTime=@EndTime,ClassSerNo=@ClassSerNo,InsSerNo=@InsSerNo where Schedule_id=@SchID", con);
                cmd.Parameters.AddWithValue("@SchID", txtschid.Text);
                cmd.Parameters.AddWithValue("@CourseID", txtcourseid.Text);
                cmd.Parameters.AddWithValue("@Day", cbodayname.SelectedItem.Text);
                cmd.Parameters.AddWithValue("@StartTime", txtstarttime.Text);
                cmd.Parameters.AddWithValue("@EndTime", txtendtime.Text);
                cmd.Parameters.AddWithValue("@ClassSerNo", txtclassserno.Text);
                cmd.Parameters.AddWithValue("@InsSerNo", DBC.InstID);
                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                }

f86e33552044747e502a612a6d305004
thanks
regards
sumith

When Loading your data into the dropdownlist try adding if(!IsPostBack){}

Hi Fenrir

It is already addded,

thanks
regards
sumith

 if (!IsPostBack)
            {
                ListItem sun = new ListItem("SUNDAY", "1");
                ListItem mon = new ListItem("MONDAY", "2");
                ListItem tue = new ListItem("TUESDAY", "3");
                ListItem wed = new ListItem("WEDNESDAY", "4");
                ListItem thu = new ListItem("THURSDAY", "5");
                ListItem fri = new ListItem("FRIDAY", "6");
                ListItem sat = new ListItem("SATURDAY", "7");


                cbodayname.Items.Add(sun);
                cbodayname.Items.Add(mon);
                cbodayname.Items.Add(tue);
                cbodayname.Items.Add(wed);
                cbodayname.Items.Add(thu);
                cbodayname.Items.Add(fri);
                cbodayname.Items.Add(sat);
                }

Here are screen shot attached i have coded same problem but it is working fine

may be u share code of whole page that will help us to figure out where problem lies

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.