Odd SelectedIndexChanged behavior on DropDownLists
Been coding away on my senior project to meet our deadline for delivery in like 4 weeks and ran into this interesting problem over the weekend.
Had three drop down lists, Campus, Course, and Semester. As one was selected, the next one was populated with the courses at the campus, and then the semesters a course was offered.
All looked good until I went to test it. The course list would get populated, but when I selected a course, it would post back, but it was never getting to the SelectedIndexChanged method. It was posting, it had a selected index, the event was wired up, but nothing would work.
After going through trial and error, I found that it was because I was populating the course drop down with ListItems ( dropCourse.Items.Add(new ListItem(course.Name, course.ID.ToString()); ). If I populated it with just the straight string ( dropCourse.Items.Add(course.Name); ) then it would work.
Anyone encountered this behavior before? I found it very odd that populating it one way would override the SelectedIndexChanged. I filled the campus drop down with ListItems, so it must have something to do with clearing it and refilling. I'd read some about the need to do ClearSelection(), and I was doing that, but it did no good either.