DataView.Sort loses ASC/DESC value

K

Kubuli John

I use a DataView object as the datasource for an ASP.NET DataGrid. I
am seting the DataView.Sort member with a column name and a direction,
eg:

dvEmp.Sort = "emp_name DESC";

This works fine, but when I post back to the page and look at the
dvEmp.Sort value, it only contains "emp_name", and appears to have
discarded the " DESC" specifier. Despite this, the dataview is
actually sorted correctly in descending order.

What gives?

John H.
 
W

William Ryan eMVP

I'd need to look at your code to be 100 % sure, but I bet it's losing it's
state (resetting itself) on the post back. Store the grid in session state
and bind to it so you can maintain it's state through post backs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top