Databinding SelectedItem/SelectedValue in a DropDownList

9 posts, 1 answers
  1. Svein Thomas
    Svein Thomas avatar
    47 posts
    Member since:
    Nov 2010

    Posted 16 Nov 2010 Link to this post

    Hi guys,

    How can i databind the selecteditem/selectedvalue in a Dropdownlist allready bounded to a table.

    Table looks like this:
    int ID, string Name;

    The DropDownlist is binded to a table of values (datasource). The DisplayMember is set to a "Name" and ValueMember is set to "ID".
    I want to use the ValueMember in another kind of binding.

    So i tried to do like this. radDropDownList1.DataBindings.Add("Value", MyDataObject, "TextID");

    But then i found out that the raddropDownList1 do not contain the Property Value, but it have a SelectedValue.

    So i tried to do like this. radDropDownList1.DataBindings.Add("SelectedValue", MyDataObject, "TextID");
    But this did not work as expected.

    So how do i do it?

    Regards
    Svein Thomas
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Nov 2010 Link to this post

    Hello,

    I'm not sure if I understand what you want to do here. I understand that you have a RadDropDownList and that it is bound to a datasource containing Name as the Display Member and Id as the Value member.

    Are you saying that you would like to pull the Selected Value or Selected Text from a datasource?
    Please ellaborate and I'll do my best to help
    thanks

    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Svein Thomas
    Svein Thomas avatar
    47 posts
    Member since:
    Nov 2010

    Posted 16 Nov 2010 Link to this post

    I have a "table1" that contains this
    ID, Name, TextID (foreign key to the table2)
    "Table2" like this:
    ID,Name.

    radDropDownList contains the Table2's data.
    When i select from the radDropDownList, i want to set the Table1's foreignkey to the selected value. (the ID of table2)
    All this with databinding.
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Nov 2010 Link to this post

    Hello again,

    re-reading the title of your thread, you can just set the SelectedText or SelectedValue to select the item that you want. Is this what you mean?
    Regards,
    Richard

    EDIT: Apologies - looks like we posted at the same time.
  6. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Nov 2010 Link to this post

    Hi,

    As far as I'm aware, this cannot be done through databinding the RadDropDownList. You would need to change the values in your Table1 on the SelectionChanged event of the RadDropdownList.

    If I can think of another solution, I'll let you know.
    regards,
    richard
  7. Shawn Shaddock
    Shawn Shaddock avatar
    25 posts
    Member since:
    Jun 2009

    Posted 09 Feb 2012 Link to this post

    This is unacceptable especially considering SelectedItem is in the (DataBindings) section of the property grid. I'm trying to use MVVM with this control and it's completely unusable. I need to bind the SelectedItem of the DropDownList to the SelectedItem of my ViewModel.
  8. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 14 Feb 2012 Link to this post

    Hello Shawn,

    Thank you for writing.

    I performed some tests with RadDropDownList and I can confirm that simple binding does not be work as expected. I logged the issue in our Public Issue Tracking System. I hope that we will be able to provide a solution regarding the simple binding in one of our next releases. Still, because of the nature of the issue, I am not able to provide you with a specific time frame. Here is a link to the item, where you can add your vote for it: http://www.telerik.com/support/pits.aspx#/public/winforms/9738.

    Thank you for your time and cooperation. Your Telerik points have been updated.

    Regards,
    Julian Benkov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  9. Marsh
    Marsh avatar
    1 posts
    Member since:
    Feb 2011

    Posted 15 Mar 2012 Link to this post

    Julian,

    That is not a satisfactory response.. what is the alternative???

    I have my object list bind to a Raddropdownlist. I want to set my selected item but its giving syntax error:

     'ContainerManager.Data.Supplier' cannot be converted to 'Telerik.WinControls.UI.RadListDataItem'.
  10. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 19 Mar 2012 Link to this post

    Hello Marsh,

    Please open a support ticket and send us a sample application to investigate this conversion locally. Thsi will allow us to find the best solution for the case.

    Thank you for your time and cooperation.

    All the best,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready