Question: Here we are again with the next problem in sorting.

this is a follow up question to [this question](https://stackoverflow.com/questions/975712/asp-net-gridview-sorting-with-linq-result)

I have now made a type to contain the data I need.
however, when I try to fetch the data FROM the gridview it returns null, which means I can't sort anything that is not there in the first place...

any ideas why this returns null ...

```
IEnumerable<JointServerData> data = gvServers.DataSource;
var sorted = data;
switch (p)
   {
       case "domain":
            sorted = data.OrderBy(o => o.DomainName);
            break;
       default:
            break;
    }
gvServers.DataSource = sorted;
gvServers.DataBind();

```

above is what I'm trying to do ...

Answer: 
Try to set data binding in Init event of control.
Other thing to point out is that GridView does not keep DataSource property
populated over the postbacks (for performance feasons since it would need to

serialize and roundtrip the entire data source)
-----------------------------------------------

Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

from <http://bytes.com/topic/asp-net/answers/828307-gridview1-datasource-null>
or you use linq datasource for yor linq queries. it automatically handles sorting process.