Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net gridview datasource null when sorting

Here we are again with the next problem in sorting.

this is a follow up question to this question

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 ...

like image 394
Jan W. Avatar asked Apr 23 '26 22:04

Jan W.


1 Answers

Without seeing all your code I'd have to assume that this is a PostBack issue. Website's are intrinsically stateless and you need to resolve this by either caching information between page requests or retrieving the data each time.

like image 113
Mark Avatar answered Apr 25 '26 22:04

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!