Set SelectedVaon page load eventlue property

2 posts, 0 answers
  1. Edwin
    Edwin avatar
    2 posts
    Member since:
    Feb 2011

    Posted 09 Feb 2011 Link to this post

    I need to set RadComboBox SelectedValue property with URL parameter value:

    ComboBox OnLoad event:
    someComboBox.DataSource = GetDataList();

    ComboBox OnDataBound event:
    someComboBox.Text = string.Empty;
    someComboBox.SelectedValue = valueFromUrlParameter;

    After page loads ComboBox is populated with data from GetDataList(), but selected value is first item in the list. It is intersting if i step through these methods in debugging mode, then value is correctly selected.
  2. Kalina
    Kalina avatar
    918 posts

    Posted 10 Feb 2011 Link to this post

    Hi Edwin,

    I suppose that this happens because the RadComboBox that you use is read-only.
    When the control is read-only there is always a selected item in it - and at initial page load this is the  first item.

    If you want to set the selected item at RadComboBox using some value obtained from Url - you can handle the OnDataBound event in this way:
    protected void someComboBox_DataBound(object sender, EventArgs e)
        var someComboBox = (RadComboBox)sender;
        someComboBox.Items.FindItemByValue("valueFromUrlParameter").Selected = true;

    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top