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

RadToggleButton and SQL Datasource Controlparameter

1 Answer 133 Views
Button
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">
                    <CommandItemTemplate>
                        <telerik:RadButton RenderMode="Lightweight" ID="_btnHideShow" runat="server" ButtonType="StandardButton"
                            ToggleType="CustomToggle" AutoPostBack="false" Skin="Metro">
                            <ToggleStates>
                                <telerik:RadButtonToggleState SecondaryIconCssClass="rbOk" Text="Show Closed Applications" Value="1"></telerik:RadButtonToggleState>
                                <telerik:RadButtonToggleState SecondaryIconCssClass="rbCancel" Text="Hide Closed Applictaions" Value="0"></telerik:RadButtonToggleState>
                            </ToggleStates>
                        </telerik:RadButton>
                    </CommandItemTemplate>
.....
    <asp:SqlDataSource ID="GetApplications" runat="server"
        ConnectionString="<%$ ConnectionStrings:PHConn %>"
        SelectCommand="Application.sp_seManageApplications" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="true">
        <SelectParameters>
            <asp:ControlParameter ControlID="_btnHideShow" PropertyName="Value" Name="DisplayCompleted" Type="Int32" DefaultValue="0" ConvertEmptyStringToNull="true" />
        </SelectParameters>
    </asp:SqlDataSource>

1 Answer, 1 is accepted

Sort by
0
Vessy
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

 

Regards,
Vessy
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.
Tags
Button
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or