2

I have a gridview with AutoGenerateColumns="true" (in general I don't know what the columns will be). Is there any easy way to sort the grid by clicking on a column header? The only solutions I have found so far are for when AutoGenerateColumns="false"

Alternatively if I know one of the columns is going to be called StatusId is there a way to sort on this column only?

Edit: I am manually updating the gridview's HeaderRow to make them more user friendly, this seems to be knocking things out. Is there a way to get round this?

openshac
  • 4,245
  • 5
  • 41
  • 69

1 Answers1

0

Did you try to Set AllowSorting="true" in the gridview ?

If that's not working for you then you can implement custom Sorting,

You can get custom sorting code from this thread: How to convert a GridView to DataTable and sort the DataTable?

Community
  • 1
  • 1
Muhammad Akhtar
  • 50,838
  • 36
  • 132
  • 186
  • Yes I did, on further investigation I can see that I am updating the values in the gridview's HeaderRow to make them more user friendly. This seems to be disabling the sorting links in the header. I'll update the original post. – openshac Jul 19 '11 at 08:16