This is a migrated thread and some comments may be shown as answers.

Setting default value

6 Answers 331 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Vijaianand
Top achievements
Rank 1
Vijaianand asked on 21 Sep 2011, 02:46 PM
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.

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2011, 05:01 AM
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.
0
Vijaianand
Top achievements
Rank 1
answered on 22 Sep 2011, 02:02 PM
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. 
0
Ivana
Telerik team
answered on 23 Sep 2011, 03:54 PM
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
0
Vijaianand
Top achievements
Rank 1
answered on 23 Sep 2011, 04:34 PM
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.?

0
Ivana
Telerik team
answered on 27 Sep 2011, 03:05 PM
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
0
Vijaianand
Top achievements
Rank 1
answered on 16 Oct 2012, 06:55 PM
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
Tags
ComboBox
Asked by
Vijaianand
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vijaianand
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or