Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 带模板字段和标题模板的GridView排序_Sorting_Gridview_Templatefield - Fatal编程技术网

Sorting 带模板字段和标题模板的GridView排序

Sorting 带模板字段和标题模板的GridView排序,sorting,gridview,templatefield,Sorting,Gridview,Templatefield,我使用的是GridView,标题单元格中有一个下拉列表用于过滤 <gm:GridView ID="routePlanGridView" runat="server" AutoGenerateColumns="False" AllowPaging="true" PageSize="20" GridLines="Both" ShowFooter="true" CssClass="grid" DataKeyNames="RoutePlanId" OnSorting="routeP

我使用的是GridView,标题单元格中有一个下拉列表用于过滤

<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>

SP名称
还有相关的事件处理程序用于排序和分页。
现在的问题是,如果我把“SP名称”文本放在一个链接按钮中,当点击链接时,页面会崩溃,否则就不会生成要排序的链接。 如果我删除标题模板字段(所有字段),并放置一个具有TemplateField的HeaderText属性的文本,它将按预期工作。有没有办法把它们放在一起?我需要那个下拉列表和排序


谢谢。

您需要为标题文本使用链接按钮。因此,使用“SP名称”代替“SP名称”。如果您正在处理排序,它应该可以工作。

您需要使用标题文本的链接按钮。因此,使用“SP名称”代替“SP名称”。如果您正在处理排序,它应该可以工作。

抱歉,忘记正确插入代码-此处:

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

抱歉,忘记正确插入代码-此处:

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


我看不出任何明显的失败原因。当你说崩溃时,你看到了一些具体的错误吗。这个错误能帮助我们得到答案吗?这里也有类似的例子不,并没有具体的错误,但Chrome说页面并没有响应kill或wait。。。如果我单击“等待”,它会再次出现(等待几分钟后)并继续运行。@Subhash:我正在执行与您提供的链接完全相同的操作(sql数据源除外)。我看不出任何明显的失败原因。当你说崩溃时,你看到了一些具体的错误吗。这个错误能帮助我们得到答案吗?这里也有类似的例子不,并没有具体的错误,但Chrome说页面并没有响应kill或wait。。。如果我单击“等待”,它会再次出现(等待几分钟后)并继续。@Subhash:我所做的与您提供的链接完全相同(sql数据源除外)。请调整您以前的答案,不要追加新的请调整您以前的答案,不要追加新的