How to set the default value

3 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 15 Sep 2012 Link to this post

    I have the following ComboBox using a data template.. I'm trying to set the default value to a selection.
    When the page loads the selection is blank.
    I've tried 

      // BIND
      var queryConf = from c in DC.conferences
                                orderby descending
                                select c;
            this.cmbConf.ItemsSource = queryConf.ToList();

    // Set DEFAULT
      this.cmbConf.SelectedItem = queryConf.ToList()[1];
       this.cmbConf.Text = (queryConf.ToList()[1] as conference).name;

    but the selection is still blank. !!!

    I have also tried

    this.cmbConf.SelectedIndex = 1;

    How can I set the default value and show the values? 
    What am I doing wrong.
    thx again

     ///  COMBOBOX

        <telerikInput:RadComboBox  TabIndex="6"  Name="cmbConf" telerik:TextSearch.TextPath="name" 
                                     FontWeight="Bold" telerikControls:StyleManager.Theme="Vista"
                                     SelectedValue="{Binding Path=id}"  SelectedValuePath="id" Width="332" >
                                    <Grid Margin="5" Width="300">
                                            <ColumnDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                        <TextBlock FontWeight="Bold" FontSize="14" x:Name="txtConf"  Text="{Binding name}" />
                                        <TextBlock Foreground="Navy" Grid.ColumnSpan="3" Grid.Row="1" Text="{Binding name_alt}" />

                                        <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,0,0,0">

                                            <TextBlock Foreground="Navy" Margin="5,0,0,0" Text="{Binding first_day, StringFormat=d}" />
                                            <TextBlock Foreground="Navy" Margin="5,0,0,0" Text=" - " />
                                            <TextBlock Foreground="Navy" Margin="5,0,0,0" Text="{Binding last_day, StringFormat=d}" />


  2. Yana
    Yana avatar
    4604 posts

    Posted 19 Sep 2012 Link to this post

    Hi Jon,

    I noticed that you've set both SelectedValuePath and SelectedValue properties -  this means that you should have a property id which needs to be set to the id property of the default value.

    The other options are to remove these properties and set SelectedItem or SelectedIndex.  I have attached a sample project showing all the approaches. Also you could check this help article for more information about selection.

    Hope this helps.

    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 19 Sep 2012 Link to this post

    thanks again!
Back to Top