我有一个gridview应该允许对所有列进行排序,并且除了第一列之外还可以正常工作。所有列标题都是可点击和可排序的。但是在第一列上sortExpression不起作用。这正发生在我正在进行的整个计划中。这是我正在使用的代码的剪辑。
<asp:GridView ID="gdvDeposit" runat="server" AutoGenerateColumns="False"
CssClass="table table-striped table-condensed table-hover table-bordered dataTable-paging"
SortedAscendingHeaderStyle-CssClass="sorting_asc" SortedDescendingHeaderStyle-CssClass="sorting_desc" PageSize="100" AllowPaging="True" AllowSorting="True"
DataSourceID="ldsDeposit">
<Columns>
<asp:TemplateField HeaderText="Deposit #" SortExpression="DepositCode" >
<ItemTemplate>
<asp:Label runat="server" ID="lblDepositNumber" Text='<%# Eval("DepositCode") %>' />
<asp:Label runat="server" Text='<%# Eval("Id") %>' Visible="false" />
<asp:HyperLink runat="server" NavigateUrl='<%# "~/Accounting/DepositEdit.aspx?Id=" + Eval("Id") %>'><i class="fa fa-pencil pull-right gdv-hover-icon" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"></i></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DepositTypeName" HeaderText="Type #" ReadOnly="true" SortExpression="DepositTypeName"></asp:BoundField>
<asp:BoundField DataField="DepositDate" HeaderText="Date" DataFormatString="{0:d}" ReadOnly="True" SortExpression="DepositDate"/>
<asp:BoundField DataField="Amount" HeaderText="Amount" ReadOnly="true" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right" SortExpression="Amount"></asp:BoundField>
<asp:BoundField DataField="PaymentsTotal" HeaderText="Payment Total" ReadOnly="true" DataFormatString="{0:C}" ItemStyle-HorizontalAlign="Right" SortExpression="PaymentsTotal"></asp:BoundField>
<asp:BoundField DataField="NumberOfPayments" HeaderText="# of Payments" ReadOnly="true" SortExpression="NumberOfPayments"></asp:BoundField>
<asp:TemplateField HeaderText="Balanced" SortExpression="Balanced">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" ID="lblPaid" Visible='<%# Eval("Balanced")%>'><i class="fa fa-check text-center"></i></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Deposited" SortExpression="Deposited">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSelect" Checked='<%# Eval("Deposited")%>' AutoPostBack="True" OnCheckedChanged="chkSelect_OnCheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>