Set selected value in code behind

5 posts, 0 answers
  1. Saeid Kdaimati
    Saeid Kdaimati avatar
    48 posts
    Member since:
    May 2006

    Posted 13 Mar 2013 Link to this post

    Hi,

    Just trying to set the selected value of combobox in code behind, but it is not working out:
    RadComboBox1.DataSource = ds.Tables[0];
    RadComboBox1.DataTextField = "Text";
    RadComboBox1.DataValueField = "ID";
    RadComboBox1.DataBind();
    if (ds.Tables[1].Rows.Count > 0)
    {
      RadComboBox1.SelectedValue = ds.Tables[1].Rows[0]["ID"].ToString();
    }

    The stored procedure I'm calling return correct data.

    Any help??
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 13 Mar 2013 Link to this post

    Hi Saeid,

    The code you posted seems to be correct. Please check returned data from the Stored Procedure once again. I'm attaching  a small sample demonstrating how this code works as expected.

    All the best,
    Hristo Valyavicharski
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 13 Mar 2013 Link to this post

    If you take your example and use Tools -> Generate Local Resource on Default.aspx in design view, SelectedValue has no effect and a blank selection is added at the top of the ComboBox.
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 18 Mar 2013 Link to this post

    Hello,

    Thank you for pointing this out. This is a development issue, which I have logged for further investigation.

    Regards,
    Hristo Valyavicharski
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 02 Jul 2013 Link to this post

    Hi Rob,

    The issue with the creation of the default item when local resources are created will be resolved in Q2.2013 SP1.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017