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

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

1 Answer 218 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
NW7US
Top achievements
Rank 1
NW7US asked on 08 Aug 2012, 12:11 PM
(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
        cboSTObject.Dispose()
  
    Next
  
    ids.Dispose()
  
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"
CausesValidation="False"></telerik:RadComboBox>
<br/>
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:EPD_DATAConnectionString %>"
SelectCommand="spGetBidSystemTypeNames" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>

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.

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 10 Aug 2012, 01:23 PM
Hello,

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.

Regards,
Kalina
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.
Tags
ComboBox
Asked by
NW7US
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or