Link to home
Start Free TrialLog in
Avatar of James Cochrane
James CochraneFlag for United States of America

asked on

Open a new page using the Select hyperlink in a datagrid

I have a datagrid that contains information with a Select hyperlink for each row.  How do I reprogram the Select hyperlink to open another form and load that particular record, i.e., it needs to get the column that contains the key and load the record into a FormView?

Thanks
Avatar of YZlat
YZlat
Flag of United States of America image

Put the following code in the DataGrid's ItemDataBound event:

 If Not e.Item.FindControl("LinkButtonID") Is Nothing Then
            Dim lbtn As LinkButton
            lbtn = e.Item.FindControl("LinkButtonID")
            If Not lbtn Is Nothing Then
                lbtn.Attributes.Add("onclick", "window.open('AddTaskPopup.aspx')")
            End If
        End If
or

 If e.Item.ID = "Select" Then
            e.Item.Attributes.Add("onclick", "window.open('AddTaskPopup.aspx')")
        End If
Avatar of James Cochrane

ASKER

Hi,

Thanks for that info.  I am using C# and there is no ItemDataBound event in C#.  There is a DataBound event but it doesn't seem to expose E.Item.FindControl.
it's ItemDataBound
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry,

I stated that I am using a DataGrid when I am actually using DataGridView.  The DataGridView doesn't seem to support those properties.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial