Can I make links in a datagrid?

T

Terry Olsen

I have a datagrid filled with shipping records. I would like to make the
field that contains the tracking numbers to be links where the user can
click and automatically track that particular shipment. Is this possible?
How would I go about it?

Thanks.
 
B

Brock Allen

Yes -- you can add a HyperLinkColumn to your grid's columns. You'll need
to specify the DataNavigateUrlFormatString which is the URL to go to but
it should have a "{0}" that will get substituted by the data from the column
you're databinding to. The column form the database to fill in should be
specified by the DataNavigateUrlField. Lastly the Text should be specified
to show the link to the user. Alternatively, you can specify a DataTextFormatString
(again with a "{0}") and a DataTextField column from the database instead
of the static Text to show as the link.

<asp:HyperLinkColumn DataNavigateUrlFormatString="UserInfo.aspx?ID={0}" DataNavigateUrlField="UserID"
DataTextFormatString="See User: {0}" DataTextField="UserName"></asp:HyperLinkColumn>
 
T

Terry Olsen

Not sure I understand the concept here. Am I supposed to add a Hyperlink
column to a grid that will receive it's data from a dataview connected to an
SQL database? Or...how do I make a certain column a hyperlink column at
runtime when no columns are defined at design time?

Sorry, this particular task is a bit confusing to me.

Thanks!
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top