asp.net网格视图中的面板-我如何在jquery中找到它
Panel inside asp.net gridview - how can I find it in jquery?
我在网格视图中有一个面板。当我单击网格视图中的单选按钮时,我调用jquery click
事件的单选按钮。那部分工作正常。。。现在我需要引用网格视图中的面板,但我不能使用$this
,因为它引用了我的单选按钮列表(我认为它引用了)。
我怎样才能得到这个小组的参考资料。
$("#MainContent_gvLineItems input[id*='rbAnswer']").click(function () {
var p = $(this).find('[id$=MainContent_gvLineItems_pnlAnswer]'); // find the panel but this wont work so what can I do here?
});
我不知道我的语法是否适合id$=MainContent_gvLineItems_pnlAnswer
,因为网格视图中的每一行的面板id都会更改。。。
编辑
以下是一些网格视图:
<asp:TemplateField HeaderText="Answer">
<ItemTemplate>
<div id="dMainAnswer">
<asp:RadioButtonList ToolTip="Please provide an answer to the method." RepeatDirection="Horizontal" ID="rbAnswer" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.AnswerID")%>'>
<asp:ListItem Text="Yes" Value="Yes" style="color:green;"></asp:ListItem>
<asp:ListItem Text="No" Value="No" style="color:red;"></asp:ListItem>
<asp:ListItem Text="N/A" Value="N/A" style="color:gray;"></asp:ListItem>
<asp:ListItem Value="" Text="" style="display: none" />
</asp:RadioButtonList>
<asp:Panel ID="pnlAnswer" runat="server" Visible="False">
<div id="dMainAnswerResponsibleType">
<asp:RadioButtonList ID="rbRespType" ToolTip="Select responsible contact type." runat="server" RepeatDirection="Horizontal" AutoPostBack="true" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.ResponsiblePartyType")%>' OnSelectedIndexChanged="rbRespType_SelectedIndexChanged">
<asp:ListItem Selected="True" Text="TKSE" Value="TKSE">TKSE</asp:ListItem>
<asp:ListItem Text="Other" Value="Other">Other</asp:ListItem>
<asp:ListItem Value="" Text="" style="display: none" />
</asp:RadioButtonList>
</div>
<div id="dMainAnswerResponsible"><a href="#" onclick="return false;" class="info">Res:<span>Select who is responsible in resolving this issue.</span></a>
<asp:DropDownList ID="ddlEmployees" runat="server"
DataSource="<%# GetEmployees() %>" SelectedValue='<%# Eval("TKSEContact") %>' DataTextField="FullName" Width="75px"
DataValueField="FullName"
ToolTip="Select the TKSE responsible party.">
</asp:DropDownList>
<asp:TextBox ID="txtContact" Text='<%# Eval("ResponsiblePartyContact") %>' Width="75px" MaxLength="50" runat="server" ToolTip="Enter the responsible contact name." Visible="false"></asp:TextBox>
</div>
<div id="dDueDate"><a href="#" onclick="return false;" class="info">Due:<span>Select the due date when you expect this issue to be resolved.</span></a>
<asp:TextBox ID="txtDueDate" Text='<%# Eval("DueDate") %>' Width="59px" runat="server" ToolTip="Select the due date." CssClass="datePickerDueDate"></asp:TextBox>
</div>
<div id="cSendToSugar">
<asp:CheckBox ID="chkSendToSugar" ToolTip="Send/Update issue to Sugar?" BackColor="Gold" Text="Send To Sugar?" Checked="true" runat="server" />
</div>
</asp:Panel>
</div>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
请注意面板pnlAnswer
,它最初设置为不可见的Visible=False
。它也不是单选按钮列表的兄弟项。。至少我不认为是…
使用.eparents查找元素的父元素;如果你给它一个css类,你可以做:
$(this).parents(".class:first")
找到它。我想这个面板是单选按钮列表的父面板。否则,您将希望使用另一个Jquery方法。只要面板是可见的,或者使用隐藏,这就可以工作
<asp:Panel .. style="display:none" />
我建议给你的面板一个css类,然后使用jQuery选择器。如果单选按钮是面板的同级按钮:
var panel = $(this).siblings(".answer");
这取决于面板在生成的标记中的位置,也许可以使用next或prev。如果你发布生成的标记,我可以更新这个答案。
现在,我们可以看到标记(谢谢),你需要父母,然后是兄弟姐妹,就像这样:
<someOtherElement> <!-- the grid view container -->
<div class="answerswer"></div> <!-- sibling of parent (maybe <div runat="server"> is better than panel?) -->
<div> <!-- parent -->
<input type="radio"> <!-- this -->
</div>
</someOtherElement>
相关文章:
- 剑道网格jQuery动画()问题
- $.每个jquery循环打印一个“;未定义的“;对于getJSON请求后的每个元素,网格数据都会完美地打印出来
- ext-js网格面板滚动条不适用于jquery
- asp.net网格视图中的面板-我如何在jquery中找到它
- Jquery网格在第二次加载时不工作
- jquery 网格中的 Spring 请求映射
- 最好的动态JavaScript/JQuery网格
- Jquery网格与Firefox的兼容问题
- JQuery网格分页不可见
- 平铺的jQuery网格
- 用javascript向jquery网格添加行
- MVC jquery网格不工作
- 不能用数据填充智能菜单jquery网格
- 过滤inffragistics jQuery网格控件时出现错误
- 砌体(JQuery网格)不工作
- 如何在内联jquery网格中定位删除对话框
- 可编辑的true在Jquery网格不起作用
- 扫雷器的JQuery网格递归(单击相邻的瓦片)
- 在jquery网格中隐藏页面导航器
- 绑定jQuery网格