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

See if combox has items selected

1 Answer 39 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 28 May 2013, 08:45 PM
What I need to do is see if any items are checked in my radcombox, if they are ass them to an string and tehn to a sql where statement,
each time I look to see if items are checked though I get errors, at this point don't know what I am doing wrong.  Need to check and see if anything checked first so that I can skip it otherwise as part of a where statement for sql.
Protected Sub myRadGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadGrid.NeedDataSource
       Dim SqlWhere As String = ""
       Dim items As String = ""
 
       If rblActive.SelectedValue = Nothing Then
           SqlWhere = " where r.bitActive = 1"
           rblActive.SelectedValue = 1
       ElseIf rblActive.SelectedValue = "All" Then
           SqlWhere = ""
       ElseIf rblActive.SelectedValue = "0" Then
           SqlWhere = " where r.bitActive = 0"
       ElseIf rblActive.SelectedValue = "1" Then
           SqlWhere = " where r.bitActive = 1"
           rblActive.SelectedValue = 1
       End If
 
       If ddlRadTeam.SelectedItem.Checked = True Then
           For Each item As RadComboBoxItem In ddlRadTeam.Items
               If item.Selected Then
                   items += item.Value & ","
               End If
           Next
       End If
 
       If ddlRadTeam.SelectedItem.Checked = True And rblActive.SelectedValue = "All" Then
           SqlWhere = " where r.intTeamId IN (" & items & ")"
       ElseIf ddlRadTeam.Items.Count > 0 Then
           SqlWhere += " and r.intTeamId IN (" & items & ")"
       End If
 
       sql = "select  " & SqlWhere
  
       myRadGrid.DataSource = getData(sql)
   End Sub

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 30 May 2013, 12:19 PM
Hello Kevin,

Would you elaborate what errors you are currently facing? In addition, I would suggest you to use the CheckedItems collection of the RadComboBox, in order to access the checked item's Text or Value.

Regards,
Nencho
Telerik
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
Kevin
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or