Using database field as link

  • Thread starter Thread starter robert.dondo
  • Start date Start date
R

robert.dondo

I have database that has one table with 2 columns ie Name and Link. I
have a page that links to the dynamic page using a query string.
The results of the query are displayed on a datagrid.

QUESTION: How do i make the text in the 'Link' Column a live link that
users can click?
 
I have database that has one table with 2 columns ie Name and Link. I
have a page that links to the dynamic page using a query string.
The results of the query are displayed on a datagrid.

QUESTION: How do i make the text in the 'Link' Column a live link that
users can click?

I'm assming your binding to the grid, so If you define
AutoGenerateColumns="false" you can specifiy the columns and their format
manually and use a hyperlink field on the column definition.


<asp:GridView ID="GridView1" runat="server"
OnPageIndexChanging="bound_PageIndexChanging"
PageSize="5"
AllowPaging=true
AutoGenerateColumns="false"
showheader="true"
CaptionAlign="Top"
RowHeaderColumn="ProductName"
BorderWidth="0px"
CellPadding="5"
TabIndex="5"
PagerSettings-Mode="Numeric"<HeaderStyle CssClass="sidebar-maintitle-dark" />
<RowStyle CssClass="MyHlStyle" />
<PagerStyle HorizontalAlign="Right"
CssClass="sidebar-maintitle-dark" />
<Columns>
<asp:BoundField ControlStyle-CssClass="MyHlStyle"
HeaderText="Title" DataField="title" ReadOnly="true" />
<asp:HyperLinkfield ItemStyle-CssClass="MyHlStyle"
DataNavigateUrlFields="link" DataTextField="description"
HeaderText="Description &amp; URL" />
</Columns>
</asp:GridView>

or you could use a templatefield

http://apnasaathi.blogspot.com/2006/09/datagrid.html

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
 
Back
Top