See if combox has items selected

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 28 May 2013 Link to this post

    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
           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
  2. Nencho
    Nencho avatar
    1877 posts

    Posted 30 May 2013 Link to this post

    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.

    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