using SelectedIndex to determine if an item was selected
-
I'm using the selectedIndex of a drop down list to determine if the user select an item If dropdownlistMember.SelectedIndex > -1 do a bunch of stuff else send an error message to the user Its a zero based drop down list The problem is that SelectedIndex is never -1. If I step through the code, when the user does not make a selection, the index is 0. If they select the first item, the index is 0 ( it should be) If they select the second item, index is 1 ( it should be) I tried initializing the index during page load if not post back If Page.IsPostBack = False Then dlIdNums.SelectedIndex = -1 But index is always 0 Any ideas? thanks
-
I'm using the selectedIndex of a drop down list to determine if the user select an item If dropdownlistMember.SelectedIndex > -1 do a bunch of stuff else send an error message to the user Its a zero based drop down list The problem is that SelectedIndex is never -1. If I step through the code, when the user does not make a selection, the index is 0. If they select the first item, the index is 0 ( it should be) If they select the second item, index is 1 ( it should be) I tried initializing the index during page load if not post back If Page.IsPostBack = False Then dlIdNums.SelectedIndex = -1 But index is always 0 Any ideas? thanks
Add a new item in the drop down with ' ' as the text and value as -1, that should be first item in the drop down. I was having the same problem i did this way. Ram
-
Add a new item in the drop down with ' ' as the text and value as -1, that should be first item in the drop down. I was having the same problem i did this way. Ram
-
Add a new item in the drop down with ' ' as the text and value as -1, that should be first item in the drop down. I was having the same problem i did this way. Ram
can't get this to work The drop down list is populated when the program is run ( by reading in records from a table) I add a new item with text ' ' and value = '1 but when I step through the code, the first item always has an index = 0 even though I've just set it to -1 Don't understand how to change this Even if no item is selected, the index is = 0 which means if no item is selected, the first item will always be selected