Solved

Open a new page using the Select hyperlink in a datagrid

Posted on 2006-11-06
8
199 Views
Last Modified: 2007-11-27
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
0
Comment
Question by:techhound
8 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17882892
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
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17882911
or

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

Author Comment

by:techhound
ID: 17883060
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.
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17883561
it's ItemDataBound
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 100 total points
ID: 17883592
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.FindControl("LinkButtonID") != null)
{
((LinkButton) e.Item.FindControl("LinkButtonID")).Attributes.Add("onclick","window.open('yourwindow.aspx');");
}
}

or

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ID="LinkButtonID")
{
e.Item..Attributes.Add("onclick","window.open('yourwindow.aspx');");
}
}
0
 

Author Comment

by:techhound
ID: 17884123
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
0
 
LVL 4

Assisted Solution

by:darkpriest
darkpriest earned 100 total points
ID: 17886677
this is psudeo cause i dont know c#

<TemplateColumn>
<itemTemplate>


<asp:HyperLink runat="serveR" id="linkMe" NavigateURL="~/yourdirectory/page.aspx?a='<%# Eval('YourIDRecord') %>'"</asp:HyperLink>


</itemTemplate>
</Template Column>
0
 
LVL 4

Accepted Solution

by:
satish_nagdev earned 300 total points
ID: 17886975
hi,
instead of ItemDatabound for datagrid you can use RowDataBound event for GridView.

regards,
satish.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now