A RadCombobox event SelectedIndexChanged fires when the control is problematically checked with exactly one checkbox item

2 posts, 0 answers
  1. NW7US
    NW7US avatar
    6 posts
    Member since:
    Aug 2012

    Posted 08 Aug 2012 Link to this post

    (The title of this thread is not quite accurate.  The title should be: "A RadComboBox event SelectedIndexChanged fires when the control is programmatically checked with exactly one checkbox item")

    I have a RadComboBox that contains CheckBox items.  I programmatically set certain items as Checked, if data exists in a database table.  Here is a segment of code:

    Dim idr As Data.DataRow
    Dim ids As Data.DataSet
    Dim idt As Data.DataTable
    Dim idtData As New Data.DataSet
    Dim iParameters(0 To 0) As Data.SqlClient.SqlParameter
    iParameters(0) = New Data.SqlClient.SqlParameter("@intBIDOID", CheckDBNull(CInt(BIDOID), enumObjectType.IntType))
    ids = clsEPD_DATA.StoredGetDataset("spGetBidsSystemTypeNames", iParameters)
    If ids.Tables(0).Rows.Count >= 1 Then
        idt = ids.Tables(0)
        For Each idr In idt.Rows
            ' "BUG" - when one and ONLY one item is check-marked, here, it causes the control to
            ' be in a state as if SelectedIndex has been changed (Telerik states this is expected).
            ' And, it stays that way, even though we set it here, and the user did NOT change anything.
            ' This is a "bug" in our scenario, where I must determine if the USER DID THE CHANGE,
            ' not the program.
            Dim cboSTObject As RadComboBoxItem = cboSystemType.FindItemByValue(CheckDBNull(idr("SYSTOID"), enumObjectType.IntType))
            cboSTObject.Checked = True
    End If
    '------------ end of System Type checkboxed combobox ----------------------

    Here is the aspx snippet:

    <telerik:RadComboBox ID="cboSystemType" runat="server" Width="200px"
    EmptyMessage="Select the System Type (if any):"
    Height="250px" DataTextField="ST_Name" DataValueField="SYSTOID"
    DataSourceID="SqlDataSource5" TabIndex="8" CheckBoxes="True"
    <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:EPD_DATAConnectionString %>"
    SelectCommand="spGetBidSystemTypeNames" SelectCommandType="StoredProcedure">

    What I would like to do is create code such that when my programmatic method changes the index (which appears only to occur when only ONE items is check-marked, but never when zero, or two or more, items are check-marked by the program), that I can somehow set the SelectedIndex code to ignore it, but when the USER MAKES A CHANGE, then I pay attention to it.  Should I create an internal variable "flag" in my program to somehow watch for when I make changes programmatically, but clear the flag?  This seems clunky.

    Any guidance would be appreciated.  Thank you.
  2. Kalina
    Kalina avatar
    918 posts

    Posted 10 Aug 2012 Link to this post


    If you use the RadComboBox Checkboxes feature - in general there is no "selected" item in the control.
    Instead of this there are CheckedItems – a collection populated with the checked items.

    When the user checks/unchecks a checkbox - the ItemChecked event fires, please handle this event instead of SelectedIndexChanged.

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