Solved

Open a new page using the Select hyperlink in a datagrid

Posted on 2006-11-06
8
205 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

718 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