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

Multiple Selection in RadComboBox within radgrid template

1 Answer 100 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Theofanis
Top achievements
Rank 1
Theofanis asked on 07 Mar 2012, 01:42 PM
Hi,
I use the Q3 2011 version of radcombobox (with the checkboxes) :

                        <FormTemplate>
                            <br />
                            <table>
                                <tr style="width: 100px">
                                    <td class="style44" style="font-family: Verdana; font-size: x-small;">
                                        Κωδ.Προϊοντος:
                                    </td>

                                    <td class="style29">

                                        <telerik:RadComboBox
                                            ID="RadComboBox1" runat="server" Filter="Contains" ItemsPerRequest="20" CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
                                            Width="350px" Height="200px"  Font-Size="X-Small" Font-Names="verdana" EnableLoadOnDemand ="true"
                                            ShowMoreResultsBox="True"
                                           
OnItemsRequested="RadComboBox1_ItemsRequested"
                                            style="margin: 20px auto; display:block !important;" />


                                            <asp:Button ID="Button1" runat="server" Text="Get Checked Items!" CssClass="qsfButtonBigger"             commandname="Button1Action" />
                                                <br />
                                            <asp:Label ID="itemsClientSide" runat="server" BorderStyle="None" CssClass="text" />
                                    </td>
                                </tr>
                            <table />
                        </FormTemplate>  

-----------------------------------------------------------------------------------------------------------------


I fill in the radCombobox with the :

    Protected Sub RadCombobox1_ItemsRequested(ByVal o As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)

        Dim data As DataTable = GetData(e.Text)
        Dim comboBox As RadComboBox = DirectCast(o, RadComboBox)
        Dim row As DataRow
        comboBox.Items.Clear()

        Dim text As String = e.Text

        If text <> "" Then
            If Len(text) >= 3 Then

                Dim rows As DataRow() = data.[Select]("newprd LIKE '" + "%" + text + "%'")

                Dim itemsPerRequest As Integer = 20
                Dim itemOffset As Integer = e.NumberOfItems
                Dim endOffset As Integer = itemOffset + itemsPerRequest
                If endOffset > rows.Length Then
                    endOffset = rows.Length
                End If

                Dim i As Integer = itemOffset
                While i < endOffset
                    comboBox.Items.Add(New RadComboBoxItem(rows(i)("newprd").ToString()))
                    System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
                    i = i + 1
                End While

                For Each row In data.Rows
                    comboBox.Items.Add(New RadComboBoxItem(row("newprd").ToString()))
                Next row

                e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, rows.Length)

            End If
        End If
    End Sub

-----------------------------------------------------------------------------------------------------------------

And the data are from :

    Private Function GetData(ByVal text As String) As DataTable
        If text <> "" Then
            If Len(text) >= 3 Then
                Dim seq As String = " SELECT prdcode as prdcode,prdtext,prdcode + '  ' + prdtext as newprd,P,D,S " + _
                                    " FROM Products_Kompass " + _
                                    " where " + _
                                    " prdcode + '  ' + prdtext like '" + "%" + Trim(text) + "%" + "'" + _
                                    " order by prdcode "

                Dim adapter As New SqlDataAdapter(seq, ConfigurationManager.ConnectionStrings("P2OPubConnectionString").ConnectionString)

                Dim data As New DataTable()
                adapter.Fill(data)
                Return data
            End If
        End If
    End Function

-----------------------------------------------------------------------------------------------------------------

When I select the items from the radcombobox and push the button (button1) :

    Protected Sub radKOMPASS_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radKOMPASS.ItemCommand

        Select Case e.CommandName

            Case "Button1Action"

                Dim cb As RadComboBox = e.Item.FindControl("RadCombobox1")
                Dim sb As New StringBuilder()
                Dim collection As IList(Of RadComboBoxItem) = cb.CheckedItems /// Here the count is zero (0) ///

                For Each item As RadComboBoxItem In Collection
                    sb.Append(item.Text + "<br />")
                Next

                Dim lb As Label = e.Item.FindControl("itemsClientSide")

                lb.Text = sb.ToString()
        End Select
    End Sub


In a few words I can't take the items which i chosen from the radcombobox. There is not any error in the code. The result is ZERO in the cb.CheckedItems.

Please,I need your help desperately. My implementation time is over.
Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 09 Mar 2012, 05:29 PM
Hi Theofanis,

By design RadComboBox items loaded via Load On Demand are not accessible at server-side.
That is why simultaneous usage of Load On Demand and CheckBoxes features is not supported.
Please find more details about this topic here.

All the best,
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
Theofanis
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or