我有一个gridview,它只是根据下拉列表中的过滤器显示记录,当我更改下拉列表时,页面回发很好并且过滤器工作,但是当我单击编辑一行时,排序顺序会根据新过滤器发生变化。当我将下拉菜单更改回原始过滤器并单击编辑时,排序顺序保持不变。
有任何想法吗?
<asp:DropDownList ID="ddlFilterDocs" runat="server"
AutoPostBack="True"
onselectedindexchanged="ddlFilterDocs_SelectedIndexChanged">
<asp:ListItem Text="MissingData"
Value="MissingData" >MissingData</asp:ListItem>
<asp:ListItem Text="AllData" Value="AllData"
>AllData</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" PageSize="35"
AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None"
onrowcommand="GridView1_RowCommand" DataKeyNames="customerCode"
onpageindexchanging="GridView1_PageIndexChanging"
onsorting="GridView1_Sorting">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField SortExpression="CustomerCode">
<ItemTemplate>
<asp:LinkButton ID="lbEdit" ForeColor="DarkGreen" Font-
Bold="True" CommandArgument='<%# Eval("customerCode") %>' CommandName="EditRow"
runat="server">Edit</asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" CommandArgument='<%#
Eval("customerCode") %>' CommandName="UpdateRow" runat="server"
ForeColor="White">Update</asp:LinkButton>
<asp:LinkButton ID="lblCancel" CommandArgument='<%#
Eval("customerCode") %>' CommandName="CancelUpdate" runat="server"
ForeColor="White">Cancel</asp:LinkButton>
</EditItemTemplate>
<HeaderStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer ID"
SortExpression="CustomerCode">
<EditItemTemplate>
<asp:Label ID="lblCustCodeEdit" runat="server" Text='<%#
Eval("CustomerCode") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCustCode" runat="server" Text='<%#
Bind("CustomerCode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name"
ReadOnly="True" >
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:TemplateField HeaderText="StreetAddress"
SortExpression="StreetAddress">
<EditItemTemplate>
<asp:TextBox ID="tbxStreetAddress" runat="server"
Text='<%# Bind("StreetAddress") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblStreetAddress" runat="server" Text='<%#
Bind("StreetAddress") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="150px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="City" SortExpression="City">
<EditItemTemplate>
<asp:TextBox ID="tbxCity" runat="server" Text='<%#
Bind("City") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCity" runat="server" Text='<%#
Bind("City") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Zip" SortExpression="Zip">
<EditItemTemplate>
<asp:TextBox ID="tbxZip" runat="server" Text='<%#
Bind("Zip") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblZip" runat="server" Text='<%#
Bind("Zip") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="50px" />
</asp:TemplateField>
<asp:BoundField DataField="DocNumber" HeaderText="DocNumber"
SortExpression="DocNumber" ReadOnly="True">
<HeaderStyle Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="GrossAmount" HeaderText="Gross"
SortExpression="GrossAmount" ReadOnly="True"
DataFormatString="{0:c2}" >
<HeaderStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="NetAmount" HeaderText="Net"
SortExpression="NetAmount" ReadOnly="True" DataFormatString="
{0:c2}" >
<HeaderStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="VATAmount" HeaderText="VAT"
SortExpression="VATAmount" ReadOnly="True" DataFormatString="
{0:c2}" >
<HeaderStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="FromVoucNbr" HeaderText="Voucher"
SortExpression="FromVoucNbr" ReadOnly="True" >
<HeaderStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="LastModDate" HeaderText="Date"
SortExpression="LastModDate" ReadOnly="True"
DataFormatString="{0:G}" >
<HeaderStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="LastModUser" HeaderText="LastModUser"
SortExpression="LastModUser" ReadOnly="True">
<HeaderStyle Width="50px" />
</asp:BoundField>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>