views:

32

answers:

2

Hi i have a gridview with information about documents: name, document type (policy, guidelines, forms, etc), category, etc. I want to sort the gridview alphabetically (name) and by document type, but always having the 'policy' above the other document types when document name is the same. How do I do that?

eg If I do sort by DocumentName, DocumentType ('policy' maybe not be the first one in the list) but if I do sort by DocumentType , DocumentName (I would get for example all guidelines first in alphabetical order, then procedures, then policies, etc)

A: 

Use the GridView.SortExpression

rick schott
A: 

Maybe do it in the database?

Perhaps do a select to get the policy documents in one query, and then UNION it to a separate query which does a search that excludes policy documents and includes a sort. for example

select * from documents where documenttype = 'policy'
UNION all select * from documents where documenttype != 'policy' order by documenttype
Dkong