This is a migrated thread and some comments may be shown as answers.

RadDropDownList

13 Answers 1050 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Mehdi Mirza
Top achievements
Rank 1
Mehdi Mirza asked on 02 Dec 2010, 02:27 AM
hello,

I am using RadDropDownList and binding it in Code behind using a datatable. The issue is when the form loads the RadDropdownlist displays the first record in the list and this fires the selectedindexchanged.
I want the RadDropDownlist to be in the state where the user selects the item he wants from the list and then the selectedindexchanged event fires.

Any ideas?

Thanks

13 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 02 Dec 2010, 11:08 AM
Hello,

The RadDropDownList will always show the first item, unless you speciifically set it to something else. In my view, it's not normal winforms practice to provide a blank entry as the first item that the user can deselect, and then go back to again. If you really need to have a default item, then this should be added to the datasource.

I hope this helps but let me know if you need more help.
Richard
0
Mehdi Mirza
Top achievements
Rank 1
answered on 05 Dec 2010, 05:37 PM
Hello Richard,

I disagree with your input, the Rad dropdown if i manually bind it using a datatable then it displays the first record, but if i am using dataset on the form itself and not code behind then it populates the rad dropdown leaving an empty selection at top.

thanks

Mehdi
0
Richard Slade
Top achievements
Rank 2
answered on 05 Dec 2010, 06:32 PM
Hello,

If you must have a default option, then you can use the following after binding the data

this.radDropDownList1.SelectedIndex = -1;
this.radDropDown1.Text = "Please Select A Value";

hope that helps
richard
0
Richard Slade
Top achievements
Rank 2
answered on 07 Dec 2010, 10:28 AM
Hello, 

Did this help? If so, please mark as answer so others can find the solution too. 
Thanks
Richard
0
black
Top achievements
Rank 1
answered on 28 Dec 2010, 08:40 PM
Richard Slade Thanks it worked for me
_________________________
Check out residual affiliate programs and get recurring money.
0
Richard Slade
Top achievements
Rank 2
answered on 28 Dec 2010, 10:09 PM
glad that worked for yuo. Please remember to mark as answer,
Richard
0
Peter
Telerik team
answered on 29 Dec 2010, 06:22 PM
Hi Mehdi Mirza, I am glad to hear that Richard's solution works for you. By default the first record is selected when using data-bound RadListControl or RadDropDownList and this desired behavior causes the issue. 

Should you have any other questions, do not hesitate to write back.

Kind regards, Peter
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Bruno
Top achievements
Rank 1
answered on 18 Mar 2011, 10:48 AM
I notice that the SelectedIndexChanged event of the radDropDownList is also fired when I call the Clear() method.

How can I know if the SelectedIndexChanged was fired from Clear() and not from a user selecting another listitem so I can condition my event code on it?

I can answer this question myself, but I don't like my solution: when coming from Clear() the radDropDownListWorkfolders:Items:Count is equal to 0. But that's not really clean, is it?
0
Richard Slade
Top achievements
Rank 2
answered on 18 Mar 2011, 10:53 AM
Hello Bruno,

Another way might be to not fire the event when you clear the items by removing and re-adding the event handler before and after the clear().
Hope that helps
Richard
0
Peter
Telerik team
answered on 23 Mar 2011, 02:53 PM
Hello,

Yes, it is a desired behavior, because Items.Clear removes all items, hence there are no selected items. As a result, the SelectedIndexChanged should be fired.

You can also put Items.Clear in BeginUpdate/EndUpdate block.

I hope this helps.

Regards,
Peter
the Telerik team
0
Artificial Intelligence
Top achievements
Rank 1
answered on 05 Jun 2018, 09:08 AM

it is the best practices for android learn more about it.

android development tutorial

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Jun 2018, 09:42 AM
Hello,   

I would like to note that this forum is related to the Telerik UI for WinForms product. However, your post seems to be more related to mobile development. Feel free to post in the relevant forum: https://www.telerik.com/forums

Thank you for your understanding.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
anshul
Top achievements
Rank 1
answered on 17 Mar 2021, 07:42 AM
Tags
DropDownList
Asked by
Mehdi Mirza
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Mehdi Mirza
Top achievements
Rank 1
black
Top achievements
Rank 1
Peter
Telerik team
Bruno
Top achievements
Rank 1
Artificial Intelligence
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
anshul
Top achievements
Rank 1
Share this question
or