link on datagrid

C

Chris Kennedy

I have a datagrid bound to a datareader. One of the columns contains file
name. I would like a column which acts as a link and opens a link to the
file (normally a pdf). How would I do this?
 
E

Eliyahu Goldin

You need to make a template column with a hyperlink control in item template
and databind the hyperlink to the name column.

Eliyahu
 
R

Riki

Eliyahu said:
You need to make a template column with a hyperlink control in item
template and databind the hyperlink to the name column.

Eliyahu

Or, even simpler, you could add a hyperlinkcolumn, and
set the DataTextField and DataNavigateUrlField properties
to the file name column.
 
C

Chris Kennedy

How do I set them?

Riki said:
Or, even simpler, you could add a hyperlinkcolumn, and
set the DataTextField and DataNavigateUrlField properties
to the file name column.
 
J

JiangZemin

The quickstart tutorials at www.asp.net will tell you exactly how to do
this. Look under "Web Controls Syntax Reference", section DataGrid.

HTH,
Premier JiangZemin

Chris Kennedy said:
Soory I'll be more specific. How do I do this in handwritten asp.net code
rather than in Visual Studio.
 
R

Riki

<asp:HyperLinkColumn DataNavigateUrlField="myUrlField" DataTextField="Name"
HeaderText="URL"></asp:HyperLinkColumn>

Riki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top