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

Filtering a RadGrid with a RadPanelBar

1 Answer 92 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 14 Jul 2009, 08:58 AM
Hi,

This is probably a stupid question and I am obviously missing something but I cannot seem to filter a grid from a panelbar. The panel bar is being populated by an sql datasource and this works fine, however getting the accompanying grid to list the appropriate item(s) from the database is causing me some confusion. I got this to work with a dropdownlist but the panelbar seems to be a different animal altogether. I have included the panelbar control and the grid control below. I have searched thoroughly through all forums and help documentation and can't find anything that offers some help here so any help with this would be much appreciated :)

The RadPanelBar:

<telerik:RadPanelBar runat="server" 
                                   id="LayoutPanelBar"
                                   Width="100%"
                                   Height="100%"
                                   ExpandMode="FullExpandedItem" 
                                   DataSourceID="LayoutPanelDataSource" 
                                   DataValueField="HashTableID" 
                                   Skin="Telerik" 
                                   DataFieldID="HashTableID" 
                                   DataTextField="hashText">
</telerik:RadPanelBar>
                                                
<asp:SqlDataSource ID="LayoutPanelDataSource" 
                                 runat="server" 
                                 ConnectionString="<%$ ConnectionStrings: [omitted] %>"
                                 SelectCommand="SELECT [HashTableID], [hashText], [sortOrder] FROM [tblHashTable] WHERE [Category] = 'Layouts' ORDER BY [sortOrder] ASC">
</asp:SqlDataSource>

The RadGrid:

<telerik:RadGrid ID="LayoutGridDetails" 
                          runat="server" 
                          DataSourceID="LayoutGridDataSource" 
                          GridLines="None" 
                          AllowPaging="true" 
                          PageSize="25">
    <PagerStyle Mode="NumericPages" />
    <MasterTableView TableLayout="Fixed">
        <ItemTemplate>
            <b>LayoutId:</b><%# Eval("LayoutId")%>
            <br />
            <b>LayoutName:</b><%# Eval("LayoutName")%>
            <br />
            <b>LayoutDescription:</b><%# Eval("LayoutDescription")%>
        </ItemTemplate>
    </MasterTableView>
</telerik:RadGrid>

<asp:SqlDataSource ID="LayoutGridDataSource" 
                                 runat="server" 
                                 ConnectionString="<%$ ConnectionStrings:[omitted] %>"
                                 SelectCommand="SELECT [LayoutId], [LayoutName], [LayoutDescription], [LayoutCategory] FROM [tblLayouts] WHERE [LayoutCategory] = @LayoutCategory">

    <SelectParameters>
        <asp:ControlParameter Name="LayoutCategory" PropertyName="DataTextField" ControlID="LayoutPanelBar" />
    </SelectParameters>
</asp:SqlDataSource>

I want to be able to filter the records in the tblLayouts.LayoutCategory based on the DataTextField="hashText" selected in the RadPanelBar. The hashText field from tblHashTable is nvarchar(50) and the LayoutCategory from tblLayouts is the same so there is no problem here. The DataField="HashTableID" is an Int32.

Any advice here would be appreciated, thank you.

Grant

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 16 Jul 2009, 01:08 PM
Hello Grant,

In the SelectParameters do not use the DataTextField because it will always return "hashText" but use the SelectedItem.Text field instead (it will return the real text of the selected item):

<SelectParameters> 
   <asp:ControlParameter Name="LayoutCategory" PropertyName="SelectedItem.Text" ControlID="LayoutPanelBar" /> 
</SelectParameters> 


Sincerely yours,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
PanelBar
Asked by
Mike
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Share this question
or