如何获取放置在用于更新面板的中继器中的复选框ID? [英] How to get the checkbox id that placed in a repeater for update panel?
本文介绍了如何获取放置在用于更新面板的中继器中的复选框ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在转发器内部有一个复选框,转发器位于更新面板的内部。该复选框具有一个已选中的更改事件,我需要该复选框的ID,以便可以在触发器内部的autopostbacktrigger中对其进行声明。但是我无法访问ID,因为它位于转发器内。如何获取复选框的ID?
I have checkbox inside a repeater and repeater is placed inside of an update panel. The checkbox have an checked changed event and I need the id of the checkbox so I can state it in autopostbacktrigger inside triggers. But I can't access the id as it is placed inside the repeater. How can I get the id of the checkbox?
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
<div class="col-md-4">
<div style="padding-top: 10px; padding-left: 20px;">
<asp:Panel runat="server" Style="height: 300px;" ID="pnl1" Visible="false" CssClass="panel pre-scrollable panel-default mypnl">
<!-- Default panel contents -->
<div class="panel-heading">
Job Status List
<div class="pull-right">
<a style="margin-top: -5px;" data-toggle="modal" data-target="#myModal" class="col-xs-12 btn btn-sm btn-default"><i class="glyphicon glyphicon-plus"></i></a>
</div>
</div>
<!-- List group -->
<ul class="list-group">
<asp:Repeater ID="rep1" runat="server" OnItemDataBound="rep1_ItemDataBound">
<ItemTemplate>
<li class="list-group-item">
<%# Eval("Description")%>
<div class="pull-right">
<asp:CheckBox runat="server" AutoPostBack="true" OnCheckedChanged="chkstatus_CheckedChanged" ChkDesc='<%# Eval("Description")%>' ChkId='<%# Eval("ID")%>' ID="chkstatus" />
</div>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</asp:Panel>
</div>
</div>
<div class="col-md-8">
<div style="padding-top: 10px; padding-left: 0px;">
<asp:Panel runat="server" Style="height: 166px;" ID="pnl2" Visible="false" CssClass="panel pre-scrollable panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
Job Sequence
</div>
<!-- List group -->
<ul class="list-group">
</ul>
</asp:Panel>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkstatus" EventName="Checked" />
</Triggers>
</asp:UpdatePanel>
推荐答案
如果要触发,只需注册
但是您会发现它们是这样的:
But you find them like this:
foreach (RepeaterItem item in rep1.Items)
{
CheckBox cb = item.FindControl("chkstatus") as CheckBox;
ScriptManager.GetCurrent(Page).RegisterPostBackControl(cb);
//or
ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(cb);
}
这篇关于如何获取放置在用于更新面板的中继器中的复选框ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文