Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
4 views

Language : vb

I have a table that contains a numeric field. Using this field value I generate variable numbers of CheckBoxes in a RadGrid PlaceHolder :

I am attempting reference the CheckBoxes in the selected row and do some processing if the a CheckBox is checked.

I can get the reference to the PlaceHolder : Dim phBlocksCheckBox As PlaceHolder = DirectCast(item.FindControl("phBlocksCheckBox"), PlaceHolder)

But the code to return the CheckBox reference is returning Nothing : Dim BlockCheckBox As CheckBox = DirectCast(phBlocksCheckBox.FindControl("BlockCheckBox_" & cbIndex), CheckBox)

Here is my code :

apsx :
    <div style="clear: both">
        <div style="float: right; margin-right: 10px;">
            <asp:Button ID="GenerateButton" runat="server" Text="Generate Cassette Labels" Disabled="True"/>
        </div>
    </div>

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" GridLines="None" AllowMultiRowSelection="True" AllowFilteringByColumn="True" EnableLinqExpressions="False">
        <MasterTableView AutoGenerateColumns="False">
            <PagerStyle AlwaysVisible="True"></PagerStyle>
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="checkboxColumn1" HeaderTooltip="SELECT All" ShowSortIcon="False" ShowFilterIcon="False" Reorderable="False">
                    <HeaderStyle Width="30px" />
                </telerik:GridClientSelectColumn>
                <telerik:GridBoundColumn DataField="NumberOfBlocks" HeaderText="Block Count" UniqueName="NumberOfBlocks" AllowFiltering="False" Display="False">
                    <HeaderStyle Width="20px" />
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="Block" HeaderText="Blocks" UniqueName="Blocks" AllowFiltering="False">
                    <ItemTemplate>
                        <asp:PlaceHolder ID="phBlocksCheckBox" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>


vb :
    Public dt As DataTable = Nothing
    Protected Sub RadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        If dt Is Nothing Then
            Dim objRadGrid As RadGrid = CType(sender, RadGrid)
            Dim objCommand As New MySqlCommand
            dt = New DataTable()

 
            objCommand.CommandText = "SELECT Block AS NumberOfBlocks FROM samples"
            Call DBClass.TapDB("ConnStr", objCommand, "getRS", "", dt)

            objRadGrid.DataSource = dt
        End If
    End Sub

    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
        'Ensure we are dealing with a data item (not header, footer, etc.)
        If TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)

            'Find the placeholder control defined in the ItemTemplate
            Dim phBlocksCheckBox As PlaceHolder = CType(item.FindControl("phBlocksCheckBox"), PlaceHolder)

            If phBlocksCheckBox IsNot Nothing Then
                Dim NumberOfBlocks As Integer = DataBinder.Eval(item.DataItem, "NumberOfBlocks")

                'Dynamically create and add checkboxes
                If NumberOfBlocks > 0 Then
                    For BlockIndex As Integer = 0 To NumberOfBlocks - 1
                        Dim BlockCheckBox As New CheckBox()
                        BlockCheckBox.ID = "BlockCheckBox_" & (BlockIndex + 1).ToString()
                        BlockCheckBox.Text = (BlockIndex + 1).ToString()
                        BlockCheckBox.Checked = True
                        phBlocksCheckBox.Controls.Add(BlockCheckBox)
                        phBlocksCheckBox.Controls.Add(New LiteralControl("    "))
                    Next
                End If
            End If
        End If
    End Sub


    Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GenerateCassetteLabelsButton.Click
        Dim NumberOfBlocks As Integer = 0

        For Each item As GridDataItem In RadGrid1.SelectedItems
            NumberOfBlocks = CInt(item("NumberOfBlocks").Text)

            Dim phBlocksCheckBox As PlaceHolder = DirectCast(item.FindControl("phBlocksCheckBox"), PlaceHolder)
            If phBlocksCheckBox IsNot Nothing Then
HttpContext.Current.Response.Write("phBlocksCheckBox IsNot Nothing<br><br>")
                For cbIndex As Integer = 1 To NumberOfBlocks
HttpContext.Current.Response.Write("-BlockCheckBoxID : " & "BlockCheckBox_" & cbIndex & "<br><br>")
                    Dim BlockCheckBox As CheckBox = DirectCast(phBlocksCheckBox.FindControl("BlockCheckBox_" & cbIndex), CheckBox)

                    If BlockCheckBox IsNot Nothing Then
HttpContext.Current.Response.Write("BlockCheckBox IsNot Nothing<br><br>")
                        'Do something with BlockCheckBox.Text
HttpContext.Current.Response.Write("Block : " & BlockCheckBox.Text & "<br><br>")
                    End If
                Next
            End If
        Next

        RadGrid1.Rebind()
    End Sub

 

Wei
Top achievements
Rank 1
Iron
Iron
 asked on 26 Feb 2026
1 answer
51 views

Hi sir,

 

 

              I open the new page in radwindow. in that new page i add textbox, checkbox, RadRadioButtonList and comobobox.

but CheckBox, RadRadioButtonList  it show double how we restrict.

it show in firefox, edge browser.

 

Rumen
Telerik team
 answered on 28 Aug 2025
0 answers
242 views

I would like to know how to customize the "X items checked" text when I set CheckedItemsTexts="FitInInput" and have multiple items checked.

Thanks

ghini
Top achievements
Rank 2
 asked on 01 Dec 2023
0 answers
200 views

I am creating a mobile website using radcomboboxes inside of update controls that are set to autopostback = true.  All of the controls work except on the page's initial load the UI elements are enlarged and look more like buttons.  They are still able to be selected and after the controls postback the elements still do not go back to a normal size. Only after a postback from another control do the UI elements shrink down to a normal size.  

I have tested the radcombobox with checkboxes enabled outside of the update panel and this behavior does not change.  I have a master page that contains jQuery files located in the header, and when I remove one of the js files, the problem disappears with the UI elements disappearing.  Can anyone help me figure out what is preventing the UI elements from rendering properly?

On Load:

   

After postback:

 

 

1 answer
144 views

I haven't used Telerik for some time and I'm trying to add a RadCheckBox whose datasource is an integer value in a column of a datarow. In the web page I've got this :

<telerik:RadCheckBox ID="chkProrataEnabled" runat="server" text="" TabIndex="7" Value='<%# DataBinder.Eval(Container, "DataItem.Prorata_Enabled") %>' autopostback="false" OnCheckedChanged="chkProrataEnabled_CheckedChanged">
</telerik:RadCheckBox>

but the check box is not being populated so I'm thinking some form of conversion from int to bool is required but not sure how to go about this. I was thinking I could change the DataBinder.Eval to check the integer value and return a true/false bool ?

 

CP
Top achievements
Rank 1
Iron
 answered on 25 May 2023
1 answer
187 views
I have added Mail Merge field and and try to add checkbox property using Telerik word processing. but not able to find the solution. and not able to extract Mail Merge fields also from word document.
Yoan
Telerik team
 answered on 05 Apr 2023
0 answers
209 views

I am trying to capture a persons ethnicity with a RadCheckBoxList control. 

I have the RadCheckBoxList inside a RadDataForm.  The RadDataForm is bound to an object data source (retrieves person records), and the RadCheckBosList is also bound to another object data source (retrieves all available ethnicities).

Where I am struggling is when you want to view an existing person record.  How to I get the ethnicity values that were previously selected to "pre-select" the correct item within the RadCheckBoxList?

Jonathan
Top achievements
Rank 1
Iron
 asked on 15 Nov 2022
1 answer
459 views

Hi,

I have a "checkbox list" with a few items. The problem is, that when the text for the item is too long it will change its alignment from let to centre automatically.

I need that text to stay left alignment no matter how long it is. 

Please see the attached image to understand what I mean.

Regards,

Omar

 

 

 

Doncho
Telerik team
 answered on 17 Jun 2022
3 answers
786 views

Hi,

is it possible to show the checkbox text on the left side of the checkbox?

<telerik:RadCheckBox runat="server" ID="CloneTripOppositeCheckBox" RenderMode="Lightweight"  Text="label_checkbox" TEXTPOSITION="LEFT"
></telerik:RadCheckBox>

Thank you
Charles
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 14 Jun 2022
1 answer
334 views

When I use the Rad radio button and checkboxes... something is messing up the alignments.  I have reviewed my css, in page style changes and inspected the page in chrome and edge and I cannot find what is causing this (looks like all the applied styles are coming from Telerik.Web.

Any thoughts on where to fix this?

Peter Milchev
Telerik team
 answered on 04 Apr 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?