SharePoint Tip of the Day : Render a link within a SPGridView

    <SharePointWebControls:SPGridView runat="server" ID="spgridviewApprovalTasks" DataSourceID="dataSourceApprovalTasks" AutoGenerateColumns="false" EmptyDataText="<p><i>Nothing is waiting for approval.</i></p>">
             <asp:BoundField HeaderText="Task" DataField="Task" />
             <asp:BoundField HeaderText="Created on" DataField="Created on" />
             <asp:BoundField HeaderText="Description" DataField="Description" HtmlEncode="False" />
             <asp:BoundField HeaderText="Status" DataField="Status" />
             <asp:BoundField HeaderText="Comments" DataField="Comments" />
             <asp:TemplateField HeaderText="Page">
                      <a href='<%#new SPFieldUrlValue(Convert.ToString(Eval("Element To Approve"))).Url%>' style='white-space:nowrap'>&rarr; view the media</a>

Now I have to remember how to use the field name instead of display name within the SPGridView because it's damn ugly to rely on the display name !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s