Archive for August, 2012

Okay, I’ve not blogged for sometime. So here a quick one just as a memory jogger for myself.

I needed to add a SharePoint URL field to a GridView to display data from a SP link list.  Here’s how i did it.

Code Snippet
  1. <asp:TemplateField>
  2.                         <HeaderTemplate>
  3.                           Title
  4.                         </HeaderTemplate>
  5.                         <ItemTemplate>
  6.                             <asp:Hyperlink NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "URL").ToString().Split(new string[] {", "}, StringSplitOptions.RemoveEmptyEntries)[0]%>' Text='<%#DataBinder.Eval(Container.DataItem, "URL").ToString().Split(new string[] {", "}, StringSplitOptions.RemoveEmptyEntries)[1]%>' runat="server"></asp:Hyperlink>
  7.                         </ItemTemplate>
  8.                     </asp:TemplateField>

I know its not rocket science and there’s probably a better way to do it, but a least I won’t have to trawl through Google again to find the answer.

More to come soon. Need to get back into blogging…

Advertisements