1
votes

I'm using GridView and there is a dropdownlist in header cell for filtering.

<gm:GridView ID="routePlanGridView" runat="server" AutoGenerateColumns="False"
    AllowPaging="true" PageSize="20" GridLines="Both" ShowFooter="true" CssClass="grid"
    DataKeyNames="RoutePlanId" OnSorting="routePlanGridView_Sorting"
    AllowSorting="true" OnPageIndexChanging="routePlanGridView_PageIndexChanging"
    OnSelectedIndexChanging="routePlanGridView_SelectedIndexChanging"
    OnRowDataBound="routePlanGridView_RowDataBound"
    OnRowEditing="routePlanGridView_RowEditing"
    OnRowUpdating="routePlanGridView_RowUpdating">
    <HeaderStyle CssClass="gridHeaderFooter" />
    <FooterStyle CssClass="gridHeaderFooter" />
    <RowStyle CssClass="gridRow" />
    <AlternatingRowStyle CssClass="gridRowAlternate" />
    <Columns>
        <asp:TemplateField SortExpression="SPName">
            <HeaderTemplate>
                SP Name<br />
                <asp:DropDownList ID="spNameFilterDDL" runat="server" CssClass="gridControl" AutoPostBack="true" DataSourceID="SPNameSDS" DataTextField="SPName" OnDataBound="filterDDL_DataBound" OnSelectedIndexChanged="spNameFilterDDL_SelectedIndexChanged" />
            </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="spNameLabel" runat="server" Text='<%# Bind("SPName") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <...15 more...>
    </Columns>
</gm:GridView>

and there are relevant event handlers for sorting and paging.
Now the problem is if I put "SP Name" text in a link button, page crashes when link clicked, otherwise no link produced to sort. If I remove Header Template fields (all of them) and put a text with HeaderText attribute of TemplateField it works as expected. Is there a way to put them together? I need that dropdown and also sorting.

Thanks.

2
I dont see any obvious reason for this to fail. When you say crash, do you see some specific error. May be that error help us to get answer? Also similar example exists here as well eggheadcafe.com/tutorials/aspnet/… - Subhash Dike
No, there is no specific error but Chrome says page is not responding kill or wait... if I click wait, it appears again (after waiting for couple of minutes) and it goes on. - Savas
@Subhash: I'm doing exactly the same (except sql data source) as the link you provided. - Savas

2 Answers

2
votes

sorry, forgot to insert the code correctly - here:

<asp:LinkButton runat="server" Text="SP Name" CommandName="Sort" CommandArgument="SPName" ></asp:LinkButton> 
-1
votes

You need to use a link button for your header text. So in place of "SP Name", use . It should work if you are handling sorting.