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

RadCombobox SelectedIndexChanged fire when program add DataSource property

3 Answers 234 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Avelyn Teh
Top achievements
Rank 1
Avelyn Teh asked on 19 Sep 2011, 09:54 AM
Dear All,

I have 2 Radcombox
Radcombox1 will bind data in Form_Load event  And  Radcombox2 will bind when user selected item at Radcombox1

This is my code in Form_LoadRadcombox1.NullText = "- Select Name -"
Radcombox1.DisplayMember = "Name"
Radcombox1.ValueMember = "ID"
Radcombox1.DataSource = dataTable
Radcombox1.SelectedItem = vbNullString

My problem is when add DataSource to Radcombox1 (Radcombox1.DataSource = dataTable)
the Radcombox1_SelectedIndexChanged event is fire and it's also binding Radcombox2.

Please suggest how to make it Binding Radcombox2, only when user selected Item at Radcombox1.

Thanks and best regards


*question re-post from TrialUser

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Sep 2011, 09:44 AM
Hi Avelyn Teh,

Đ¢his a normal and expected behavior, because the DataSource changed the current position to 0, so the event should be fired. You can workaround this with a BeginUpdate/EndUpdate block:

Radcombox1.NullText = "- Select Name -"Radcombox1.DisplayMember = "Name" 
Radcombox1.BeginUpdate() 
Radcombox1.ValueMember = "ID" 
Radcombox1.DataSource = dataTable  
Radcombox1.SelectedItem = vbNullString 
Radcombox1.EndUpdate()
I hope it helps. If you have any further questions, do not hesitate to contact me.

Best wishes,
Peter
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
NW7US
Top achievements
Rank 1
answered on 07 Aug 2012, 03:43 PM
In my scenario, I have a RadComboBox that contains CheckBox items.  I problematically set certain items as Checked, if data exists in a database table.  Here is a segment of code:

' now, check anything that is really checked.
 
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 pro grammatically, but clear the flag?  This seems clunky.

Any guidance would be appreciated.  Thank you.
0
Stefan
Telerik team
answered on 08 Aug 2012, 06:04 AM
Hello Tomas,

Your question seems to concern RadComboBox for ASP.NET AJAX, while this forum is for RadComboBox for WinForms. If so, please address your question in the ASP.NET AJAX forums: http://www.telerik.com/community/forums/aspnet-ajax/combobox.aspx

Regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Avelyn Teh
Top achievements
Rank 1
Answers by
Peter
Telerik team
NW7US
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or