如何查找FooterTemplate里的控件.

在Repeater控件,ListView控件中都有FooterTemplate模板.但你在后台中如何去找FooterTemplate中的控件呢?

 

如.<FooterTemplate>
    <tr>

          <td style="padding-left:10px; text-align:left;">

               <asp:Label ID="lbCurrency" runat="server" Font-Bold="true" />

          </td>

     </tr>  

</table>

     </FooterTemplate>

这样就可以找到了:

  Label lbCurrency = (Label)ListView1.Controls[toolList.Controls.Count - 1].FindControl("lbCurrency"); //ListView1是这个主控件,或许是Repeater1

 

注意*:在FooterTemplate里只有一个tr,如果有2个tr的,那么上面的写法就要改动一点点了.大家应该可以推理的出来.

原文地址:https://www.cnblogs.com/qfb620/p/1281298.html