ddPersonList.SelectedValue gave me the valuefield of the selected item (autopostbackflags is set to on). Since upgrading to 10.1 i get a null reference exeption.
When stepping the code ddpersonlist.SelectedItemIndex gave me 358 (correct) but still the selectedvalue is null reference.
What happened? Help (quick!) is appreciated!
Hi,
I cannot determine what's the cause of this issue without looking at some code (ASPX + code behind). That would help me a lot in resolving it.
Thank you,
Angel
Can anyone help? I'm totally stuck and getting frustrated.
Thank you for your reply.
SelectedItemIndex only gives me the index... I need the value of the item chosen, the index does me no good really. With or without the DataBind() (and removing the if postpack line), I get the same results. I get a correct value for SelectedItemIndex but SelectedValue gives me a null reference error.
On one hand, you have a good point that this was working before. But it wasn't working properly , so the new behavior you are seeing is caused by this fix. The issue was that if i set a data source, and then change the data source to some completely different data source, the selected index and selected value weren't necessarily reset. What could happen is that if my new data source has less items, my index can be now out of range, or even worse, it can be in range, but point to the wrong item.
In fact, the microsoft dropdownlist control behaves in the same way as the WebDropDown is currently behaving. If the control is bound to a data source object, it requires its data source to be set every time in code behind, otherwise data items will not be persisted.
As a workaround, you can get save the Selected Index in some variable (SelectedItemIndex)., then call DataBind(), and then just get the item's value by index, provided you have stored the actual index:
int selectedIndex = dropDown.SelectedItemIndex;
dropDown.DataBind();
dropDown.Items[selectedIndex].Value; // that's the desired SelectedValue
again, the MS asp:DropDownList behaves in the same way.
Hope it helps,
When I use the typeahead, here is what it's doing.
If I type ahead and say 2 items show up in the list: if I pick the first item, the text I had typed remains in the dropdown instead of the item I selected. If I select anything OTHER than the first item, the item then properly shows up in the list. If I then go select the first item, it shows up fine. But if the very first time I select the first item in the list, it will not then replace the text in the dropdown.
I will check this out and let you know asap. By the way, if the first item is already selected, selection won't be changed (events also won't fire because we are selecting the same item again).
Thanks,
Hey,
You can refer to the following thread, it discusses the same issue. We are going to fix it for the next service release. In the meantime you can use the workaround suggested in my last post in this thread:
http://forums.infragistics.com/forums/t/34601.aspx