GridView通过Container在前台页面访问并找到绑定模版中控件

<asp:GridView ID="GVStat" runat="server" AutoGenerateColumns="False" Width="90%" AllowPaging="false">
    <Columns>
      <asp:TemplateField HeaderText="col2">
        <ItemTemplate>
          <asp:TextBox ID="txt2" MaxLength="3" Width="30" runat="server" Text='<%# Eval("col2") %>'></asp:TextBox>
          <%#  ((Container as GridViewRow).FindControl("txt2") as TextBox).ClientID %>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
      </asp:TemplateField>
    </Columns>
  </asp:GridView>

posted @ 2013-05-31 11:38  云城  阅读(193)  评论(0编辑  收藏  举报