[英]Accessing Eval value inside Gridview Using JQuery OR JavaScript
I have gridview
with four columns
. 我有四columns
gridview
。 All the data inside is generated in RowDataBound
event using Literals
eg. 内部的所有数据都是使用Literals
在RowDataBound
事件中生成的。
<asp:TemplateField HeaderText="" >
<ItemTemplate>
<asp:HiddenField ID="ID" Value='<%#Eval("id")%>' runat="server" />
<asp:Literal ID="ltrImage" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
and
<asp:TemplateField HeaderText="" HeaderStyle-HorizontalAlign="Center"
ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Literal ID="lrtBrief" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
In one of these Literals
I am creating a <a>
tag and I want to find the <%#Eval("id")%>
value in click
event of the <a>
tag. 在这些Literals
之一中,我正在创建一个<a>
标记,并且希望在<a>
标记的click
事件中找到<%#Eval("id")%>
值。
I did try something like this but didn't work 我确实尝试过类似的方法,但是没有用
$('.contactLink').click(function () {
var grd = $('#MainContent_cphMain_DisplayResults1_gvDisplay');
var txt = $(grd).find("cells[1].innerHTML").html();
});
HTML Looks Like this HTML看起来像这样
<td align="center" style="width:5%;">
<input id="MainContent_cphMain_DisplaySearchResults1_gvListing_Listing_0" type="hidden" value="1" name="ctl00$ctl00$MainContent$cphMain$DisplaySearchResults1$gvListing$ctl02$Listing">
<table class="contact">
<tbody>
<tr>
<td valign="top">
<h3>Test</h3>
<h3>
<a id="hlContact" class="contactLink format" runat="server">Contact</a>
<a id="hlViewF" class="viewLink format" href="CategoriesSearch.aspx?ID=1" runat="server">View </a>
</td>
</tr>
</tbody>
</table>
</td>
Any help will be appreciate 任何帮助将不胜感激
Thanks 谢谢
if I understand your question right: 如果我理解您的问题是对的:
In one of these Literals I am creating a tag and I want to find the <%#Eval("id")%> value in click event of the tag. 在这些文字之一中,我正在创建一个标签,并且想在标签的click事件中找到<%#Eval(“ id”)%>值。
I would say something like this would do the trick 我会说类似的东西可以解决问题
$('a').live("click", function () {
alert($(this).attr("id"))
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.