Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai sir i have anchor tag in grid view like this


<asp:GridView runat="server" ID="grdAuthors" AutoGenerateColumns="false"
GridLines="None" ShowHeader="false" onrowcommand="grdAuthors_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<li>
<a href="#inline1" id="various1" > </a>


</li>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

i want to bind one text from database to anchor tag..

Upon clicking on text i need to open a popup... Here i used like this


<div id="inline1" style="width:520px;display: none; height:400; overflow:auto;">

<table width="100%" border="0" cellspacing="5" cellpadding="6" class="tbt">
<tr>
<td > <asp:Image runat="server" ID="imgAuthor" Height="100px" /></td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" class="tbt">

<asp:GridView runat="server" ID="grdPopup" AutoGenerateColumns="false" GridLines="None" ShowHeader="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>

<tr>
<td align="right" valign="top" width="70%">Name</td>
<td align="center" valign="top" width="2%">:</td>
<td align="left" valign="top" width="28%"><strong><asp:Label runat="server" Text='<%#Eval("AuthorName") %>' ID="lblAuthorName"></asp:Label></strong></td>
</tr>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td align="right" valign="top">Email Id</td>
<td align="center" valign="top">:</td>
<td align="left" valign="top"><strong><asp:Label runat="server" ID="lblEmailId" Text='<%#Eval("Email") %>'></asp:Label> </strong></td>
</tr>

</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td align="right" valign="top" width="70%">About Author</td>
<td align="center" valign="top">:</td>
<td align="left" valign="top"> <asp:Label runat="server" ID="lblDescription" Text='<%#Eval("Description") %>'></asp:Label> </td>
</tr>
</ItemTemplate>
</asp:TemplateField>

</Columns>

</asp:GridView>

</table>
</td>
</tr>
</table>
</div>

Please help me
Posted
Comments
JoCodes 29-Nov-13 3:52am    
Wont it be better if using hyperlink control instead of anchor tag so that we can use the onlclick event

1 solution

Hi
try this code...

do modifications as per your requirements


C#
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="POC.WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <script src="jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        var openpopup = function () {
            document.getElementById('inline1').style.visibility = 'visible';
        }
        var closepopup = function () {
            document.getElementById('inline1').style.visibility = 'hidden';
        }
        
    </script>
    <title></title>
</head>
<body>
    <form id="form1"  runat="server">
    <asp:GridView ID="gv" runat="server">
        <Columns>
            <asp:TemplateField HeaderText="header text ">
                <ItemTemplate>
                    <li><a href="#inline1"  önclick="openpopup()" id="various1">
                        <%# Eval("value")%></a></li>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div id="inline1" style="width: 520px; background-color: Blue; height: 400; overflow: auto;
        visibility: hidden">
        <table width="100%" border="0" cellspacing="5" cellpadding="6" class="tbt">
            <tr>
                <td>
                 <asp:Button ID="Button1" OnClientClick="closepopup(); return false;" runat="server" Text="close" />
                </td>
                <td>
                    <h2>
                        your content to display .......
                    </h2>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
v2

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