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.
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.