Posted
on May 10, 2011 in Technical Tips | 1 comment
I am amazed how difficult it was to find simple examples of exposing a hyperlink in an asp.net gridview control. I tried some obvious things that didn’t work at first, but I got four different approaches working that I thought I would share for others that run into this [I would assume] common need.
In my case, I wanted to hyperlink to an external site based, passing in the external url along with an ID passed in as a URL parameter.
For example: http://www.externalsite.com?myID=1234
Construct URL Inside SQL
This is old code that had the SQL query inside a SqlDataSource control, so I first thought of just adding the column there:
SELECT '<a href="http://www.externalsite.com?myID=' + CONVERT(VARCHAR,MY_FIELD) + '">Link</a>' Link, ...
By default, this rendered the actual HTML encoded hyperlink inside the grid: Link
This was easily remedied by either of the following approaches:
<Columns>
<asp:BoundField HtmlEncode="false" DataField="Link" HeaderText="Link" SortExpression="Link" />
</Columns>
Note: The key here is HtmlEncode="false"
<Columns>
<asp:TemplateField HeaderText="Link">
<ItemTemplate>
<%# Eval ("Link") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
Construct URL Outside of SQL
The other two approaches do not rely on the URL being generated inside the SQL, but instead leveraging the ObjectId when constructing the URL in the GridView:
<Columns>
<asp:HyperLinkField Text="Link" Target="_blank" DataNavigateUrlFields="ObjectId" DataNavigateUrlFormatString="http://www.externalsite.com?myID={0}" />
</Columns>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" Text="Link" Target="_blank" NavigateUrl='<%# "http://www.externalsite.com?myID=" + Eval("ObjectId")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
Posted
on Dec 20, 2010 in Technical Tips | 1 comment
Here are quick shortcut keys I use when using SQL Sever Management Studio’s query editor (I happen to be on version 2008 R2).
- Comment selection: CTRL-K, C (while holding CTRL)
- Uncomment selection: CTRL-K, U (while holding CTRL)
- New Query Editor Window: CTRL-N
- Find: CTRL-F (F3 for next occurrence, SHIFT-F3 for previous occurrence)
- Replace: CTRL-H
- Word completion: ALT+RIGHT ARROW
- List members: CTRL-SPACE
- Next Editor Window: CTRL-TAB (previous CTRL-SHIFT-TAB) —- this works like Textpad
These are some of my favorites out of the full list of SQL Server Management Studio shortcuts published by Microsoft.
More to come in an update, but wanted to get these listed here in draft form to help my team members and perhaps others on the internet that like to have efficient text editor capabilities in the RDBMS IDEs.
Show line numbers with Tools > Options > Text Editor > All Languages > Display > Line Numbers (as below):

Posted
on Nov 21, 2010 in Technical Tips | 0 comments
I talk to many customers who have trouble understanding the Microsoft SharePoint versions that have existed since around 2003, so I have provided a very simple chart with the various naming conventions used in the industry.
read more
Recent Comments