Archive

Archive for the ‘LINQ’ Category

LINQ is really REALLY nice :)

Ran into a little problem having to do with setting some things on a SPGridView-column after databind.

Luckily I ran into this post, which helped me get a shorter version for the same purpose:

DataControlFieldCell dcfcDescription = e.Row.Cells.OfType<DataControlFieldCell>().Where(c => c.ContainingField.SortExpression == "Description").Select(c => c).SingleOrDefault();
if (dcfcDescription != null)
{
    Label desc = (Label)dcfcDescription.Controls[0];
    dcfcDescription.ToolTip = desc.Text;

    if (desc != null && desc.Text.Length > 100)
    { desc.Text = desc.Text.Substring(0, 50) + " ..."; }
}

I love being able to use LINQ on objects that were not originally designed for that :D

Categories: C#, LINQ Tags: ,

LINQ/Lambda and SharePoint

I just ran into a very nice article about using Lambda’s/LINQ on SharePoint objects.
You can find it here.

Categories: Lambda, LINQ, SharePoint Tags: , ,
Follow

Get every new post delivered to your Inbox.