Current filter:
                                You should refresh the page.
                                Support Center

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

                                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 TemplateControl. Sometimes it's hard to correctly build the ControlParameter's ControlID property manually, so it's better to build it at runtime. In fact, the ControlParameter's ControlID property equals the UniqueID property of an external ASPxComboBox.

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

                                You must  log in  or  register  to leave comments
                                Select file
                                • Default.aspx
                                • Default.aspx.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2009 vol 3.3 - v2010 vol 1.12
                                <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
                                <%@ Register Assembly="DevExpress.Web.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
                                <%@ Register Assembly="DevExpress.Web.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
                                <%@ Register Assembly="DevExpress.Web.ASPxGridView.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
                                <%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.3, Version=9.3.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
                                    Namespace="DevExpress.Web.ASPxEditors" 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 runat="server">
                                    <title></title>
                                </head>
                                <body>
                                    <form id="mainForm" runat="server">
                                    <div>
                                        <dx:ASPxRoundPanel ID="ASPxRoundPanelContainer" runat="server" Width="200px" HeaderText="Naming Container">
                                            <HeaderTemplate>
                                                <dx:ASPxLabel ID="ASPxLabelCaption" runat="server" Text="Select Category">
                                                </dx:ASPxLabel>
                                                <dx:ASPxComboBox ID="ASPxComboBoxCategoriesInHeader" runat="server" ValueField="CategoryID"
                                                    TextField="CategoryName" ValueType="System.Int32" DataSourceID="SqlDataSourceCategories"
                                                    AutoPostBack="True" OnLoad="ASPxComboBoxCategoriesInHeader_Load">
                                                </dx:ASPxComboBox>
                                            </HeaderTemplate>
                                            <PanelCollection>
                                                <dx:PanelContent ID="MainPanelContent" runat="server">
                                                    <dx:ASPxGridView ID="ASPxGridViewProducts" runat="server" 
                                                        DataSourceID="SqlDataSourceProducts" 
                                                        OnBeforePerformDataSelect="ASPxGridViewProducts_BeforePerformDataSelect">
                                                    </dx:ASPxGridView>
                                                </dx:PanelContent>
                                            </PanelCollection>
                                        </dx:ASPxRoundPanel>
                                    </div>
                                    <asp:SqlDataSource ID="SqlDataSourceCategories" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                        SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource>
                                    <asp:SqlDataSource ID="SqlDataSourceProducts" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                                        SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice], [Discontinued] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
                                        <SelectParameters>
                                            <asp:ControlParameter 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