Current filter:
                                You should refresh the page.
                                Support Center

                                How to filter ASPxGridView bound to SqlDataSource by using an external ASPxComboBox in ASPxRoundPanel

                                0

                                This example demonstrates how to filter the ASPxGridView bound to SqlDataSource via the ControlParameter. The ControlParameter is passed to the SqlDataSource from an external ASPxComboBox. The ASPxComboBox is inside ASPxRoundPanel. Use the following syntax to find the ASPxComboBox inside the ASPxRoundPanel: ASPxRoundPanelID$ASPxComboBoxID.

                                See also:
                                E2041

                                You must  log in  or  register  to leave comments
                                Show Implementation Details


                                Select file
                                • Default.aspx
                                • Default.aspx.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2013 vol 1.6 - v2013 vol 2.9
                                • v2009 vol 3.3 - v2012 vol 2.16
                                <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
                                
                                <%@ Register assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
                                
                                
                                <%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
                                
                                <%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
                                
                                <%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
                                
                                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                                <html xmlns="http://www.w3.org/1999/xhtml">
                                <head id="Head1" runat="server">
                                    <title></title>
                                </head>
                                <body>
                                    <form id="mainForm" runat="server">
                                        <div>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="200px" HeaderText="Naming Container">
                                                            <PanelCollection>
                                                                <dx:PanelContent ID="PanelContent1" runat="server">
                                                                    <dx:ASPxLabel ID="ASPxLabelCaption1" runat="server" Text="Select Category">
                                                                    </dx:ASPxLabel>
                                                                    <dx:ASPxComboBox ID="ASPxComboBoxCategoriesInContent" runat="server" ValueField="CategoryID"
                                                                        TextField="CategoryName" ValueType="System.Int32" DataSourceID="SqlDataSourceCategories"
                                                                        AutoPostBack="True">
                                                                    </dx:ASPxComboBox>
                                                                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="SqlDataSourceProducts1">
                                                                    </dx:ASPxGridView>
                                                                </dx:PanelContent>
                                                            </PanelCollection>
                                                        </dx:ASPxRoundPanel>
                                                    </td>
                                                    <td>
                                                        <dx:ASPxRoundPanel ID="ASPxRoundPanel2" runat="server" Width="200px" HeaderText="Naming Container">
                                                            <HeaderTemplate>
                                                                <dx:ASPxLabel ID="ASPxLabelCaption2" runat="server" Text="Select Category">
                                                                </dx:ASPxLabel>
                                                                <dx:ASPxComboBox ID="ASPxComboBoxCategoriesInHeader" runat="server" ValueField="CategoryID"
                                                                    TextField="CategoryName" ValueType="System.Int32" DataSourceID="SqlDataSourceCategories"
                                                                    AutoPostBack="True">
                                                                </dx:ASPxComboBox>
                                                            </HeaderTemplate>
                                                            <PanelCollection>
                                                                <dx:PanelContent ID="PanelContent2" runat="server">
                                                                    <dx:ASPxGridView ID="ASPxGridView2" runat="server" DataSourceID="SqlDataSourceProducts2">
                                                                    </dx:ASPxGridView>
                                                                </dx:PanelContent>
                                                            </PanelCollection>
                                                        </dx:ASPxRoundPanel>
                                                    </td>
                                                </tr>
                                            </table>
                                
                                        </div>
                                        <asp:SqlDataSource ID="SqlDataSourceCategories" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                            SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource>
                                
                                        <asp:SqlDataSource ID="SqlDataSourceProducts1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                            SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice], [Discontinued] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="ASPxRoundPanel1$ASPxComboBoxCategoriesInContent"
                                                    Name="CategoryID" PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                
                                        <asp:SqlDataSource ID="SqlDataSourceProducts2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                            SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice], [Discontinued] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="ASPxRoundPanel2$HTC$TC$ASPxComboBoxCategoriesInHeader"
                                                    Name="CategoryID" PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </form>
                                </body>
                                </html>

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners