patriotpacer
asked on
Grid View - Keep Sort
I have a very simple .NET page with a gridview with headers that are sortable. However, when I use the code below to filter the gridview, I lose my sort ability.
How do I fix?
How do I fix?
protected void submit_Click(object sender, EventArgs e)
{
try {
SqlDataSource2.SelectCommand = "SELECT * FROM [table WHERE [inspector] = '" + DropDownList1.SelectedValue + "'";
GridView1.DataBind();
}
catch
{
}
}
can you post your gridview code here ?
ASKER
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"
DataSourceID="SqlDataSource1" Font-Size="X-Small" GridLines="Horizontal"
PageSize="20">
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="CUSTOMER" HeaderText="CUSTOMER"
SortExpression="CUSTOMER" />
<asp:BoundField DataField="DEALER" HeaderText="DEALER"
SortExpression="DEALER" />
<asp:BoundField DataField="ACCOUNT_NUMBER" DataFormatString="{0:C}"
HeaderText="ACCOUNT_NUMBER" SortExpression="ACCOUNT_NUMBER" />
<asp:BoundField DataField="CREDIT_AVAILABLE" DataFormatString="{0:C}"
HeaderText="CREDIT_AVAILABLE" SortExpression="CREDIT_AVAILABLE" />
<asp:BoundField DataField="CREDIT_LIMIT" DataFormatString="{0:C}"
HeaderText="CREDIT_LIMIT" SortExpression="LIMIT" />
<asp:BoundField DataField="Credit_USED" HeaderText="Credit_USED"
SortExpression="Credit_USED" />
<asp:BoundField DataField="CITY" HeaderText="CITY" SortExpression="CITY" />
<asp:BoundField DataField="STATE" HeaderText="STATE" SortExpression="STATE" />
<asp:BoundField DataField="ZIPCODE" HeaderText="ZIPCODE"
SortExpression="ZIPCODE" />
<asp:BoundField DataField="AUDIT_INTERVAL" HeaderText="INTERVAL"
SortExpression="AUDIT_INTERVAL" />
<asp:BoundField DataField="INSPECTOR" HeaderText="INSPECTOR"
SortExpression="INSPECTOR" />
<asp:BoundField DataField="CONSECUTIVE_AUDITS" HeaderText="CONSECUTIVE_AUDITS"
SortExpression="CONSECUTIVE_AUDITS" />
<asp:BoundField DataField="MANAGER" HeaderText="MANAGER"
SortExpression="MANAGER" />
<asp:BoundField DataField="R" HeaderText="R" SortExpression="R" />
<asp:BoundField DataField="T" HeaderText="T" SortExpression="T" />
<asp:BoundField DataField="Q" HeaderText="Q" SortExpression="Q" />
</Columns>
<FooterStyle BackColor="#B5C7DE" Font-Size="Large" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<SortedAscendingCellStyle BackColor="#F4F4FD" />
<SortedAscendingHeaderStyle BackColor="#5A4C9D" />
<SortedDescendingCellStyle BackColor="#D8D8F0" />
<SortedDescendingHeaderStyle BackColor="#3E3277" />
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx. I apologize but probably be a day before I can test.