Hi I have a radlistbox with SelectionMode="Multiselect". I want to get the count of checked items of listbox on button click. I tried to get the count by finding control on button click event but i am not able to find the control.
HTML Code:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Width="100%">
<div>
<asp:Table>
<asp:TableRow>
<asp:TableHeaderCell>
<telerik:RadLabel ID="RadLabel_abc" runat="server" Text="ABC"></telerik:RadLabel>
</asp:TableHeaderCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<telerik:RadListBox ID="rlbAbc" runat="server"
Height="100px"
Width="480px"
AllowTransfer="false"
AllowTransferOnDoubleClick="false"
TransferToID="rlbChosen"
EnableDragAndDrop="true"
OnClientTransferring="rlbAbc_OnClientTransferring"
CheckBoxes="true"
ButtonSettings-ShowTransferAll="false"
EnableViewState="false"
SelectionMode="Multiple"/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</telerik:RadAjaxPanel>
.VB File
Protected Sub RadButton_AddToList_Click(sender As Object, e As EventArgs)
GetSelectedItemText("rlbABC")
End Sub
Public Function GetSelectedItemText(ByVal controlID As String) As String
Dim theListbox As RadListBox = CType(FindControl(controlID), RadListBox)
For idx As Integer = 0 To theListbox.Items.Count - 1
Dim li As RadListBoxItem = theListbox.Items(idx)
If theListbox.Items(idx).Selected = True Then
Return theListbox.Items(idx).Text
End If
Next
Return Nothing
End Function
But I am not able to find control. Can anyone suggest a better way to do this. My main objective is to get count of checked items of list box on button click