> I have the following code
>
[quoted text clipped - 5 lines]
> This obviouslay doesnt work, what am I doing wrong. I want the ability
> to sort on a column name - how can I do this?
One of the purposes of LINQ is to make queries correct at compile time.
How many potential orderings do you have? You could do something like:
IEnumerable<Products> data1;
switch (orderByFieldName)
{
case "ProductName":
{
data1 = nw.Products.OrderBy(p => p.ProductName);
}
case "ProductID":
{
data1 = nw.Products.OrderBy(p => productID);
}
// etc
}
Alternatively, I believe Marc Gravell has some code to produce an
appropriate expression tree from a property name if you really want to
go that route.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk