Enable a RadTextbox from RadCombox

5 posts, 1 answers
  1. Ebenezer
    Ebenezer avatar
    39 posts
    Member since:
    Dec 2012

    Posted 13 Mar 2013 Link to this post

    I have a RadCombox bound to sql datasource with some dropdown items. There is one column called "Other". I want when users select the other, it enable a corresponding RadTextbox so they can input an item and on save button click the item get save to the other column in the database. Any example?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Mar 2013 Link to this post

    Hello,

    Please have a look into the following sample code.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1"
        OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" DataTextField="ContactName">
        <DefaultItem runat="server" Text="Select" />
    </telerik:RadComboBox>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="select ContactName from [Customers]"></asp:SqlDataSource>
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Style="margin-left:50px; visibility:hidden;">
    </telerik:RadTextBox>

    JavaScript:
    <script type="text/javascript">
        function OnClientSelectedIndexChanged(sender, args) {
            var textbox = $find("<%= RadTextBox1.ClientID %>");
            if (args._item._text == "Other") {
                textbox._element.style.visibility = "visible";
            }
            else {
                textbox._element.style.visibility = "hidden";
            }
        }
    </script>

    Then on the server side click event of a RadButton you can save the text in database and hide the RadTextBox.

    Thanks,
    Princy.
  3. Ebenezer
    Ebenezer avatar
    39 posts
    Member since:
    Dec 2012

    Posted 14 Mar 2013 Link to this post

    Hi Princy
    Thanks. But at the same time I am getting 'Telerik.Web.UI.RadComboBox' does not have a public proprty named 'DefaultItem'
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Mar 2013 Link to this post

    Hello,

    The DefaultItem property of RadComboBox was introduced in the Q3 2012 release (version 2012.3.1016). Since you are getting Telerik.Web.UI.RadComboBox' does not have a public proprty named 'DefaultItem' error message, I think you are having a older version of DLL which does not have this feature. Check the version and try upgrading to the latest release of RadControls.

    Thanks,
    Princy.
  5. Ebenezer
    Ebenezer avatar
    39 posts
    Member since:
    Dec 2012

    Posted 15 Mar 2013 Link to this post

    Thanks very much
Back to Top