Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys

I have a gridview with hyperlinks, when a mouse hovers over the link and clicks the link, it is supposed to go to the target page. Any ideas how I can generate the target links?
Posted
Updated 12-Oct-10 21:49pm
v2

You can assign the target links to these hyperlinks in RowDataBound event of gridview.
 
Share this answer
 
You can form the target links using <%# Eval
Or otherwise as Brij Suggested.
 
Share this answer
 
v3
Comments
Anele Ngqandu 13-Oct-10 6:16am    
The "<%# Eval >" is'nt it suppose to be on the gridView?
In this case the gridView gets information from the database and if a new item is added to the database, the gridView is updated and I do have the pages but I dont have an Idea How am i gona link them.


//below is my grid view
<asp:gridview ID="gridViewCognosCourses" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" Height="128px" Width="532px"
OnRowDataBound="gridViewCognosCourses_RowDataBound" CssClass="links"
>
<rowstyle backcolor="#FFFBD6" forecolor="#333333">
<footerstyle backcolor="#990000" font-bold="True" forecolor="White">
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#c1481b" Font-Bold="True" ForeColor="#FFFFFF " />
<AlternatingRowStyle BackColor="White" />


</asp:gridview>


//below is the code behind for the gridView

protected void gridViewCognosCourses_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";

e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.gridViewCognosCourses, "Select$" + e.Row.RowIndex);
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900