Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Open a new page using the Select hyperlink in a datagrid

Posted on 2006-11-06
8
202 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Expert Comment

by:YZlat
ID: 17883561
it's ItemDataBound
0
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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