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

Dropdown or combobox inputs values to control parameter

1 Answer 242 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Brian Palmer
Top achievements
Rank 1
Brian Palmer asked on 13 Nov 2009, 06:26 PM
Hi,

I have a radtoolbar with aa combo-box (RadComboBox1) inside a template.  I want to input the value selected the combo-box to a datasource control parameter.  I'm not sure how to do it.  The combo-box control ID is not listed when I modify the datasource.

Thanks in advance for the help. 

Here's the code for the toolbar:

 

<telerik:RadToolBar ID="RadToolBar1" runat="server" Width="100%" 

 

BorderStyle="None" Skin="Sitefinity">

 

 

 

<Items 

 

 

<telerik:RadToolBarButton runat="server" Text="New">

 

</telerik:RadToolBarButton>

 

 

 

<telerik:RadToolBarButton runat="server" Text="Filter">

 

 

 

<ItemTemplate>

 

 

 

<telerik:RadComboBox ID="RadComboBox1" AutoPostBack="True" Runat="server">

 

 

 

<Items>

 

 

 

<telerik:RadComboBoxItem runat="server" Selected="True" Text="All" Value="0" />

 

 

 

<telerik:RadComboBoxItem runat="server" Text="All Open Requests" Value="1" />

 

 

 

<telerik:RadComboBoxItem runat="server" Text="My Open Requests" Value="2" />

 

 

 

<telerik:RadComboBoxItem runat="server" Text="My Closed Requests" Value="3" />

 

 

</Items>

 

</telerik:RadComboBox>
</ItemTemplate>
</telerik:RadToolBarButton>

 

 

 

<telerik:RadToolBarButton runat="server" Text="Edit">

 

 

 

</telerik:RadToolBarButton>

 

 

 

<telerik:RadToolBarButton runat="server" Text="Print">

 

 

 

</telerik:RadToolBarButton>

 

 

 

<telerik:RadToolBarButton runat="server" Text="Search">

 

 

 

</telerik:RadToolBarButton>

 

 

 

<telerik:RadToolBarButton runat="server" Text="Refresh">

 

 

 

</telerik:RadToolBarButton>

 

 

 

</Items>

 

 

 

</telerik:RadToolBar>

 

 

 

 

 

 


Here's the code for the datasource:

<

 

asp:SqlDataSource ID="sqldsRequestsFiltered" runat="server"

 

 

 

ConnectionString=""

 

 

 

SelectCommand="csp_ith_ssl_requests_filtered" SelectCommandType="StoredProcedure">

 

 

 

<SelectParameters>

 

 

 

<asp:ControlParameter ControlID="RadComboBox1" Name="selection"

 

 

 

PropertyName="SelectedValue" Type="Int32" />

 

 

 

<asp:ControlParameter ControlID="lblUserName" Name="userid" PropertyName="Text"

 

 

 

Type="String" />

 

 

 

</SelectParameters>

 

 

 

</asp:SqlDataSource>

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 18 Nov 2009, 02:36 PM
Hello Brian,

One workaround is to handle the Selecting event of your SqlDataSource similar to this demo and find the RadComboBox in code behind:
* * *
 <SelectParameters>
            <asp:Parameter Name="selection" Type="String" DefaultValue="0" />
        </SelectParameters>
* * *


protected void sqldsRequestsFiltered_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        RadComboBox selectionComboBox = RadToolBar1.FindItemByText("Filter").FindControl("RadComboBox1") as RadComboBox;
        e.Command.Parameters["@selection"].Value = selectionComboBox.SelectedValue;
    }


Cheers,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ToolBar
Asked by
Brian Palmer
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or