LINQ is really REALLY nice :)
·91 words·1 min
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