C# .NET - hyperlink in the gridview - Asked By santoshk kumar on 08-May-08 11:08 AM

i want a hyperlink to be appered in a column of gridview and if i click on that hyperlink it shud display the total row of that particular hyperlink in a separate gridview

here it is - Santhosh N replied to santoshk kumar on 08-May-08 11:29 AM

check this for creating a hyperlink column and after doing this, you can write the logic to display the number and other stuff in the respective page..

<asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="White"
            BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" 

GridLines="None" AutoGenerateColumns="False">
            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                <asp:BoundField DataField="CategoryID" />
                <asp:HyperLinkField DataNavigateUrlFields="CategoryID"

                    DataTextField="CategoryName" NavigateUrl="SmallWindow.aspx" />
                <asp:BoundField DataField="Description" />

Can - Rave Rasaiyah replied to santoshk kumar on 08-May-08 09:42 PM

Nice put update panel with in gridview  and when u click hyperlink update hyperlink text value by the roo count in datasource.
tha's all.

Here is an eg: - chakradhar koturu replied to santoshk kumar on 08-May-08 10:19 PM


Here s an example to use hyperlink in gridview.Have alook

<asp:GridView ID="urlGrid" runat="server" AutoGenerateColumns="False">
            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem,"SiteId","RedirectToUrl.aspx?SiteId={0}" ) %>'
      <asp:BoundField DataField="SiteName" HeaderText="Site Name" />

RE - Swapnil Salunke replied to santoshk kumar on 09-May-08 12:26 AM


In particularly I have done the same thing in my grid here is part of code that would help you

<asp:TemplateField HeaderText="MessageData" SortExpression="MessageData" meta:resourcekey="TemplateFieldResource4">


<a id="A1" href="#" forecolor="Red" onclick="javascript:OpenWindow('<%#DataBinder.Eval(Container.DataItem,"Msg2")%>')" title="Click here to see the whole message" runat="server"><%#DataBinder.Eval(Container.DataItem, "MessageData")%></a>



Hope it will help you

Happy Coding

Takecare Bye

hyperlink in the gridview - SP replied to santoshk kumar on 09-May-08 12:45 AM
you can set your hyperlink in gridview column in RowBoundEvent. and on hyperlink click call another gridview by passing the value.
First let the second gridview be invisible. when you click the hyperlink, pass its value and fetch the records from the database
and bind the second gridview and make it visible.
Try this - Sagar P replied to santoshk kumar on 09-May-08 08:34 AM

<asp:TemplateField >


<asp:HyperLink ID="hyp1" Text="click here" runat="server" Target="_parent"></asp:HyperLink>



onclick of that hyperlink you can show anothere gridview.