?
Solved

Open a new page using the Select hyperlink in a datagrid

Posted on 2006-11-06
8
Medium Priority
?
206 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
[X]
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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:YZlat
ID: 17883561
it's ItemDataBound
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 400 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 400 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 1200 total points
ID: 17886975
hi,
instead of ItemDatabound for datagrid you can use RowDataBound event for GridView.

regards,
satish.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

762 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