|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add a dropdownlist to the column header in a GridView?Hello,
I would like to add a dropdownlist to the column header in a grid view to facilitate filtering the records based on the selected value in the dropdownlist. Is this possible? If yes, how do I accomplish that. Any help is greatly appreciated. Thanks, Felix.J Hello,
I figured it out myself. However, the events for the dropdownlist are not firing. Any ideas? Thanks, Felix.J Show quoteHide quote "Felix_WafyTech" <Felix_WafyTech@community.nospam> wrote in message news:#oYgFynSGHA.1236@TK2MSFTNGP11.phx.gbl... > Hello, > > I would like to add a dropdownlist to the column header in a grid view to > facilitate filtering the records based on the selected value in the > dropdownlist. Is this possible? If yes, how do I accomplish that. Any help > is greatly appreciated. > > Thanks, > Felix.J > > Hi Felix,
Thank you for posting. As for adding a dropdownlist to gridview's certain column header and make it sort the gridview when selectedIndex changes, I think you need to check the following things: 1. Make sure the dropdownlist control has been set to AutoPostback = true, this will make it postback whenever the client user change the selected item in it. 2. Make sure the dropdownlist's "SelectedIndexChanged" event has been attached an event handler (your custom event handler). Here is the aspx template for a test gridview which contains a column which embed a dropdownlist in it: ======================= <Columns> <asp:TemplateField ShowHeader="False"> <EditItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </EditItemTemplate> <HeaderTemplate> <asp:DropDownList ID="lstSort" runat="server" AutoPostBack="True" OnPreRender="lstSort_PreRender" OnSelectedIndexChanged="lstSort_SelectedIndexChanged" > <asp:ListItem>CategoryID</asp:ListItem><asp:ListItem>CategoryName</asp:ListItem> <asp:ListItem>Description</asp:ListItem> </asp:DropDownList> </HeaderTemplate> ........................................... ==================================== Hope this helps. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
How to access control in FormView
Are you sure? for delete in GridView FormView vs create How to get CommandField and ButtonField in the toolbox? paging control? GridView and DetailsView/FormView in seperate pages FormView sample that includes edit/delete? DataView, DataTable, or DataSet? Custom Web control question Disable CommandField for some rows of data |
|||||||||||||||||||||||