Setting default value

7 posts, 0 answers
  1. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 21 Sep 2011 Link to this post

    I am using the RadCombobox with design time datasource setting because I need to use the Itemperrequest property. I know itemperrequest and showmoreresult property don't work if you have dynamic datasource setting. Because of designtime datasource setup, I don't know how to set the default value to the combo using valuefield. 

    Help me here.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Sep 2011 Link to this post

    Hello VijayAnand,

    You can try the following code library approach to achieve your scenario.
    Setting an initial value in RadComboBox while using Load on Demand.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 22 Sep 2011 Link to this post

    It doesn't show how to set the default value. It only shows how to load the combobox with filtered data. I need to set the combo to a value checking the value field. 
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 23 Sep 2011 Link to this post

    Hi Vijaianand,

    You could subscribe to the OnClientItemsRequested client-side event and set a selected item from there.

    Here is an example:
    function OnClientItemsRequested(sender, eventArgs) {
        var items = sender.get_items();
        var firstItem = items.getItem(0);
        firstItem.select();
    }

    Hope this helps.

    Greetings,
    Ivana
    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. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 23 Sep 2011 Link to this post

    I guess I wasn't clear about my requirement. I have the combobox. If I load runtime, I cannot use Itemperrequest and Showmoreresult stuff since its a restriction. If I loaded using design time sqldatasource, I don't have access to the data in codebehind and I am not able to set the initial value from it. So what is the solution to set initial value for the combobox not select item.?

  7. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 27 Sep 2011 Link to this post

    Hello Vijaianand,

    You could use the EmptyMessage property of the RadComboBox to set an initial value.

    You could refer to the following help article, to see how to insert a default item when databinding the RadComboBox: Insert a default item when databinding RadComboBox.

    Also, you could take a look at the automatic load on demand example on our website:
    RadComboBox: Automatic Load on Demand.

    Hope this helps.

    Best wishes,
    Ivana
    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
  8. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 16 Oct 2012 Link to this post

    I was able to figure out the right answer from some help.
    If Not TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject Then
                Dim dv As System.Data.DataRowView = CType(_dtItem, System.Data.DataRowView)
                If dv IsNot Nothing Then
    Dim selectedItem As New RadComboBoxItem()
                    selectedItem.Value = dv.Row.Item("NetworkManagerId").ToString
                    NetworkManagerId.Items.Add(selectedItem)
                    selectedItem.Selected = True
                    selectedItem.DataBind()
    End If
    End If
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017