all groups > asp.net datagrid control > december 2004 >
You're in the

asp.net datagrid control

group:

Add Hyperlink column at runtime



Add Hyperlink column at runtime Scott Friedrich
12/28/2004 10:19:01 AM
asp.net datagrid control: I found this link in a previous thread:

http://datawebcontrols.com/faqs/

Thanks Scott Mitchell!!

That code works fine if I add the ASP code to the HTML page. What I have is
the need to set a column as a hyperlink in code at run time. I have a page
where a user can create ad hoc queries. I am determinig the datatype of the
column and if it is a hyperlink I then need to set the column in the datagrid
as a hyperlink. These queries will be different everytime and that is why I
need to dynamically set the hyperlink column(s) at run time.

Any advice greatly appreciated.

Scott Friedrich


Re: Add Hyperlink column at runtime Scott Friedrich
12/28/2004 7:39:26 PM
I figured it out. I needed to turn off AutoGenerateColumns and add them via
code..ala..

Dim col0 As New HyperLinkColumn

col0.DataTextField = dt.Columns(0).ColumnName

col0.DataNavigateUrlField = dt.Columns(0).ColumnName

col0.DataNavigateUrlFormatString = "Javascript: var w =
window.open('ViewImage.aspx?ID={0}','','width=600,height=400');"

col0.HeaderText = "URL"

Me.DataGrid1.Columns.Add(col0)

Scott





"Scott Friedrich" <Scott Friedrich@discussions.microsoft.com> wrote in
message news:6BFE6C97-C37B-49B5-B32D-7D4E4D7F7818@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button