访问 ListView 的 LayoutTemplate 中的控件 [英] Access a control inside a the LayoutTemplate of a ListView

查看:24
本文介绍了访问 ListView 的 LayoutTemplate 中的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问 ListView 控件的 LayoutTemplate 中的控件?

How do I access a Control in the LayoutTemplate of a ListView control?

我需要进入 litControlTitle 并设置它的 Text 属性.

I need to get to litControlTitle and set its Text attribute.

<asp:ListView ID="lv" runat="server">
  <LayoutTemplate>
    <asp:Literal ID="litControlTitle" runat="server" />
    <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
  </LayoutTemplate>
  <ItemTemplate>
  </ItemTemplate>
</asp:ListView>

有什么想法吗?也许通过 OnLayoutCreated 事件?

Any thoughts? Perhaps via the OnLayoutCreated event?

推荐答案

试试这个:

((Literal)lv.FindControl("litControlTitle")).Text = "Your text";

这篇关于访问 ListView 的 LayoutTemplate 中的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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