本文介绍了如何在javascript中将gridview id作为客户端ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在gridview中的价值和我有javascript函数我正在做postpack一旦我找到gridview客户端ID。但是因为我在表中使用了itemtemplate,所以javscript没有获取gridview id的客户端ID。请参阅下面我的编码。
JavaScript:
I am bingding value in gridview and i have javascript function i am doing postpack once i find gridview client id. but as i used itemtemplate in table , javscript is not taking client id of gridview id. see below my coding.
JavaScript:
<script type="text/javascript" language="javascript">
function qandans_filter_search(s) {
alert(s);
debugger;
if (s == 5) {
document.getElementById('<%= hiddenval.ClientID %>').value = s;
__doPostBack("<%=girdview1.ClientID%>", ""); // client is not coming. here coming like " table#gridview1 . so, here how to capture gridviewid as client id which stars table#ct.....gridvi..
}
else {
document.getElementById('<%= hiddenval.ClientID %>').value = s;
}
}
</script>
Gridview:
Gridview :
<asp:GridView ID="girdview1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<p><%# Eval("question") %></td> </p>
</tr>
<tr>
<p><%# Eval("answer") %></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
推荐答案
var myGrid = <%theGrid.ClientId %>
然后从那里使用myGrid。对所有客户端ID执行相同操作,使用一个定义这些内容的丑陋块,然后使用客户端变量。
And then use myGrid from there. Do the same with all your client ids, have one ugly block that defines these things, and then use the client side variables.
这篇关于如何在javascript中将gridview id作为客户端ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!