Can I make links in a datagrid?

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
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.
 
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>

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
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!
 
Back
Top