hey guys
I'm in a bit of pickle here.
up till now I have a linq query that fills a datagrid perfectly with filterconditions. however, when I try to implement sorting I fail.
I have the following code behind. it catches the start of the sort.
protected void gvServers_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection == SortDirection.Ascending)
{
SortDataAsc(e.SortExpression);
}
else if (e.SortDirection == SortDirection.Descending)
{
SortDataDesc(e.SortExpression);
}
}
in these submethods I'd want to hendle the sorting of each possible sorting expression. however, when I try to use the data that is already in the gridview it won't allow me to linq it with an orderby
private void SortDataAsc(string p)
{
var data = gvServers.DataSource;
switch (p)
{
case "domain":
var sorted = data.nothinghappenshere
default:
break;
}
}
as you can see pointing to the nothinghappenshere I cannot sort the data (proabaly because it's a var).
What I've read online is that you can just get the data from the gridview as I try to do in SortDataAsc(), but it doesn't seem to work that way.
I simply want to order by a certain field in my resultset (which is in this case an anonymous class derived from a join)
does anyone have a solution for this issue?
thx,
J.