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

RadToggleButton and SQL Datasource Controlparameter

1 Answer 107 Views
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 10 Oct 2019, 03:01 PM

I would like to pass the status of the RadToggleButton to a SQL Datasource on the page to trigger whether it should values or not.  Running into an error 

Could not find control '_btnHideShow' in ControlParameter 'DisplayCompleted'.

DisplayCompleted is the SQL Parameter that will be passed in.  I want to pass in either the 0 or 1 from the RadButtonToggleState.  

<MasterTableView AutoGenerateColumns="false" TableLayout="Fixed" HierarchyDefaultExpanded="true" AlternatingItemStyle-BackColor="LightBlue" CommandItemDisplay="Top">
                        <telerik:RadButton RenderMode="Lightweight" ID="_btnHideShow" runat="server" ButtonType="StandardButton"
                            ToggleType="CustomToggle" AutoPostBack="false" Skin="Metro">
                                <telerik:RadButtonToggleState SecondaryIconCssClass="rbOk" Text="Show Closed Applications" Value="1"></telerik:RadButtonToggleState>
                                <telerik:RadButtonToggleState SecondaryIconCssClass="rbCancel" Text="Hide Closed Applictaions" Value="0"></telerik:RadButtonToggleState>
    <asp:SqlDataSource ID="GetApplications" runat="server"
        ConnectionString="<%$ ConnectionStrings:PHConn %>"
        SelectCommand="Application.sp_seManageApplications" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="true">
            <asp:ControlParameter ControlID="_btnHideShow" PropertyName="Value" Name="DisplayCompleted" Type="Int32" DefaultValue="0" ConvertEmptyStringToNull="true" />

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 15 Oct 2019, 08:38 AM

Hi Kurt,

The Grid's CommandItemTemplate is a naming container, this is why the button cannot be passed directly by id but you have to assign it programmaticly. You can access it in the Grid's PreRender (or ItemDatabound, depending on the scenario) event in a similar way :

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs)
        Dim commandItem As GridCommandItem = CType((TryCast(sender, RadGrid)).MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
        Dim btn As RadButton = CType(commandItem.FindControl("_btnHideShow"), RadButton)
       'your logic here

    End Sub


Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Telerik team
Share this question