获取放置在DataControl内的控件的ClientID [英] Get ClientID of a Control Placed INSIDE a DataControl

查看:88
本文介绍了获取放置在DataControl内的控件的ClientID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我获取保存在DataControl的ItemTemplate中的控件的ClientID吗? 我的控制就是这样.

Can anyone help me to get the ClientID of a control which is kept in the ItemTemplate of an DataControl? My control is like this.

<asp:ListView ID="ListView1" runat="server">
            <LayoutTemplate>
                 <table ID="itemPlaceholderContainer" runat="server" border="0" style="">
                    <tr runat="server">
                        <td>Contacts</td>
                    </tr>
                    <tr id="itemPlaceholder" runat="server" >

                    </tr>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                 <tr style="">
                    <td>
                        <asp:CheckBox ID="chkFlag" runat="server" AutoPostBack="true" />
                    </td>                
                    <td><asp:Label ID="LabelContacts" runat="server" Text='<%#Eval("cont_name") %>'></asp:Label>
                    <asp:HiddenField ID="hfGSM" runat="server" Value='<%#Eval("cont_gsm") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            </asp:ListView>

我需要从此ListView内部获取CheckBox的ClientID. 有人知道怎么做吗?请帮助我

I need to get the ClientID of CheckBox from inside this ListView. Do anyone knows how to do it? Please help me in this

推荐答案

在ItemDataBound事件处理程序中……您可以找到该控件并获取客户端ID,就像这样

in the ItemDataBound event handler... you can find the control and get the client id like this

((CheckBox)e.Item.FindControl("chkFlag")).ClientID

这篇关于获取放置在DataControl内的控件的ClientID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆