Hi, I have an issue with my drop down list.
Lets say that i have a DropDownList Displaying : A, B ,C , D etc. And I need a default item.
Using this code , my data is not correctly bound.
The display of the DrowDownList Is the one i expected . But my "RDDL_Statut.SelectedItem.Value.ToString()" Is returning the Next Index.
When A is clicked I get B value.
6 Answers, 1 is accepted
Which event handler do you access the SelectedItem.Value property in? If you want to get the selected item's value I would suggest subscribing to the SelectedIndexChanged event and in its handler you can use the arguments to get it: e.Value.
I'm using the SelectedIndexChanged with my
to rebind my RadGrid.
On Selecting of my LinqDataSource I Check All my Dropdownlist With
The provided information is not enough for us to be able to determine what causes the behavior you have experienced. I would suggest isolating the DropDownList in a sample runnable project, which reproduces the issue, open a support ticket and attach it for further review. Here are our guidelines, which describe the correct approach for isolating an issue.
Let me help you reproduce this behavior.
First in the aspx :
Then in the code behind:
Btw, i never had so mutch issue posting on a forum .. The backspace refresh and the blockcode Eternal trap re fun to see.
But the ordering of a datatable is based on the sorting..
So the only way to workaround is to a dummy column in the datatable n filter on it.
this is a lot of work around when Dropdown list . Items .insert should have done it.
If there is any other solution please let me know. For now the Drop Down list have been removed.
Thank you for posting a sample runnable page.
After analyzing the code we can say that the issue is caused by rebinding the DropDownList on every postback in the RDDL_Phase_Load handler. What happens is the following:
- after a selection is made, the control initiates a postback sending the info about the SelectedIndex to the server, so for example if you select CC the SelectedIndex is 3.
- on the server the RDDL_Phase_Load handler is reached and you rebind the control which means after you call RDDL_Phase.DataBind(); the control contains one item less (the previously added --GOO GOO GOO-- item at this point does not exist in the items collection) so now the index 3 points at a different item (DD).
is not an option and you must use the control's OnLoad event and rebind it on every postback, I would suggest adding logic to the RDDL_Phase_Load handler for correcting the SelectedIndex when an item is added, for example:
Telerik by Progress