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

SelectedValue Not Working?

1 Answer 120 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bryan Kowalchuk
Top achievements
Rank 1
Bryan Kowalchuk asked on 08 Dec 2010, 10:03 PM
I have tried everthing to get the SelectedValue of a radCombo to work, but it always seems to have a value of "1".
I have a simple scenario, a radcombo in ASP.FormView in edit mode.

The combo definition looks like:
<telerik:RadComboBox ID="EmployeePotentialCombo" runat="server" DataSourceID="EmployeePotentialList"
    DataValueField="eptID" Text="Employee Potential:" DataTextField="eptDesc" Width="350px"
    EmptyMessage="Select Employee Potential" Label="Potential:">
</telerik:RadComboBox>

The list populates correctly.

First I tried to set the value this way:
<telerik:RadComboBox ID="EmployeePotentialCombo" runat="server" DataSourceID="EmployeePotentialList"
    DataValueField="eptID" Text="Employee Potential:" DataTextField="eptDesc" Width="350px"
    EmptyMessage="Select Employee Potential" Label="Potential:" SelectedValue='<%# Bind("eptID") %>'>
</telerik:RadComboBox>

With no results. Next attempt was with code-behind:
protected void FormView1_DataBound(object sender, EventArgs e)
{
    DataRowView drv = (DataRowView)FormView1.DataItem;
    RadComboBox combo = (RadComboBox)FormView1.FindControl("EmployeePotentialCombo");
    combo.SelectedValue = drv["eptID"].ToString();
   // combo.SelectedValue = "3";
}

Setting the value from the DataRowView (null) or forcing a value to "3" had no effect, SelectedItemValue was always "1"

Any ideas?

Update: The first scenario worked OK except for nul values from the database. Is there a way to show the empty message for nulls?

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 12 Dec 2010, 05:05 PM
Hi Bryan Kowalchuk,

The empty message shows only if the RadComboBox is not read-only (AllowCustomText=True). Then you can force the empty message to apply if you clear the selection in the RCB by calling ClearSelection() or the control has no Items.

I hope this helps.

Best wishes,
Simon
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.
Tags
ComboBox
Asked by
Bryan Kowalchuk
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or