SelectedValue not changed when fill Text in code

2 posts, 0 answers
  1. Ricardo
    Ricardo avatar
    22 posts
    Member since:
    Dec 2018

    Posted 22 Feb 2019 Link to this post

    After bind the DropdownList with datatable, I set the Text of the DropdownList in code, if the Text match one of element of the datatable, the SelectedValue should changed at the same time, in my case, it is not, I need to click the DropdownList to change the SelectedValue. 

    Anything I can do to sync the action that I get the right SelectedValue  when I set Text match one of element of the datatable?


  2. Dimitar
    Dimitar avatar
    2960 posts

    Posted 25 Feb 2019 Link to this post

    Hi Ricardo,

    This should work, please make sure that you are setting the text after the control is already loaded and the data source is set. 

    Another approach is to directly set the selected value: 
    public RadForm1()
        radDropDownList1.ValueMember = "Name";
        radDropDownList1.DisplayMember = "Name";
        radDropDownList1.DataSource = GetTable();
    private void RadButton1_Click(object sender, EventArgs e)
        radDropDownList1.SelectedValue = "Sam";

    I hope this helps.  

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top