This is a migrated thread and some comments may be shown as answers.
Dropdown List with RadComboBox
1 Answer 16 Views
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 28 Feb 2013, 04:21 PM
I have a datalist (dlLockNumber) with a RadComboBox Control (rcbLockSeriesLockNumbers) in it. Depending on the number of records in the datalist, there could be one to 100 (or more) RadComboBox instances of rcbLockSeriesLockNumbers. I have a RadButton named "rbSelect" for each RadComboBox that is disabled upon page load - so that when someone selects some value other than the default ("-1"), the desired event is to enable the button. I have a javascript function named OnClientSelectedIndexChanged that hopefully would work but it does not. If any of you Javascript sharpies could take a look at the function and steer me in the right direction, it would be appreciated.

Here is the HTML side of the code - this is part of a .NET User Control:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Keys.ascx.vb" Inherits="Controls_Keys" %>
<telerik:RadCodeBlock ID="rcblock1" runat="server">
<script language="javascript" type="text/javascript">
    function OnClientSelectedIndexChanged(sender, eventArgs) {
        var item = eventArgs.get_item();
        var ddl = $find("<%= dlKeySeries.ClientID %>");
        var button = ddl.get_items().getItem(0).findControl("rbSelect");
        var strValue = item.options[item.selectedIndex].value;
        if (strValue == "-1") {
            button.set_enabled(false);
        }
        else {
            button.set_enabled(true);
        }
    }
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxPanel ID="rapKeys" runat="server">
<asp:Panel ID="pnlKeysTrue" Visible="true" runat="server">
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td class="BlackSmall">
        <br />
            <asp:Literal ID="litSectionTitle" runat="server" /><br />
            <asp:Literal ID="litSectionIntro" runat="server" />
        </td>
    </tr>
    <tr id="trrcKeySeries" runat="server">
        <td class="BlackSmall">
            <br />
            <asp:DataList ID="dlLockNumber" DataKeyField="SeriesLockID" OnItemDataBound="dlLockNumber_ItemDataBound" Width="100%" RepeatDirection="Vertical" RepeatColumns="3" runat="server">
                <ItemTemplate>
                    <asp:Label ID="lblSeriesLockID" Visible="false" runat="server"><%#Databinder.Eval(Container.DataItem, "SeriesLockID") %></asp:Label>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td valign="top" style="width:196px;text-align:center">
                                <telerik:RadComboBox ID="rcbLockSeriesLockNumbers" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" CausesValidation="false" AppendDataBoundItems="true" DataValueField="LockNumberID" Width="130px" ZIndex="20000" DataTextField="LockNumber" AutoPostBack="true" runat="server"  />
                            </td>
                            <td>
                                <telerik:RadButton ID="rbSelect" Enabled="false" Skin="Sunset" OnClick="rbSelect_OnClick" runat="server" Text="Select" />
                            </td>
                        </tr>
                    </table>
                </ItemTemplate>
            </asp:DataList>
        </td>
    </tr>
</table>
</asp:Panel>

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 01 Mar 2013, 04:44 PM
Hello Greg,

With the current implementation the button is enabled in the ClientSelectedIndexChanged event, at the same time you have AutoPostBack="true" which will cause a post back once the selection is changed. Since the RadButton does not persists its enabled value when changed client-side, my suggestion is to change it in the server SelectedIndexChanged event of the RadComboBox.

Greetings,
Hristo Valyavicharski
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.
Asked by
Greg
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or