SelectedValue Not Working?

2 posts, 0 answers
  1. Bryan Kowalchuk
    Bryan Kowalchuk avatar
    19 posts
    Member since:
    Dec 2009

    Posted 08 Dec 2010 Link to this post

    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?
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 12 Dec 2010 Link to this post

    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.
Back to Top