Sunset at Oak Island, North Carolina

Spider Web Woman Designs

How to make a URL clickable in an ASP.NET GridView

In Design View, click in the GridView and click on the arrow pointing to the right. You should see Common GridView Tasks.

Choose Add New Column - this should bring up the Add Field dialog.

Choose HyperLinkField as the field type and click the Refresh Schema link. This will open up more fields to use with dropdowns to select data fields from your database.

Type the text you want to appear as your column header in the Header Text field.

For Hyperlink text, if you want generic text to appear, type it into the Specify Text field. If you want the URL to display, choose Get text from data field and select your fieldname from the dropdown.

For Hyperlink URL, choose Get URL from data field and select your field from the dropdown.

If the URL in your database in formatted as www.yourwebsite.com (without a preceding http://) type http://{0} in the URL format string box.

Click OK.

Save your page and preview in browser.

To open the hyperlink in a new window

In Design View, click on the column and click on the arrow pointing to the right. You should see Common GridView Tasks.

Choose Edit Columns

Find your field in the Selected fields list.

In the HyperLinkField properties, scroll down to Target and choose _blank from the dropdown.

Click OK.

Save your page and preview in browser.


Back to Working with Access Databases in Microsoft Expression Web

 



Email UsWe're on Google+LinkedIn ProfileFollow us on TwitterLike Us on Facebook!