Add Hyperlink column at runtime

Discussion in 'ASP .Net Datagrid Control' started by Scott Friedrich, Dec 28, 2004.

  1. 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
     
    Scott Friedrich, Dec 28, 2004
    #1
    1. Advertising

  2. 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 > wrote in
    message news:...
    > 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
    >
    >
    >
     
    Scott Friedrich, Dec 29, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    626
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
  2. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    11
    Views:
    1,028
    deandany
    Jul 17, 2006
  3. davetichenor
    Replies:
    1
    Views:
    907
    Eliyahu Goldin
    Oct 30, 2006
  4. Keith G Hicks
    Replies:
    3
    Views:
    803
    Keith G Hicks
    Feb 18, 2008
  5. Dave
    Replies:
    0
    Views:
    997
Loading...

Share This Page