<FooterTemplate>
<asp:Label ID="lblCurrentPage" runat="server" Text="1"></asp:Label> 页 / 共 <asp:Label ID="lblPageCount" runat="server" Text="1"></asp:Label> 页
</FooterTemplate>我将两个标签放在 Repeater 控件的 FooterTemplate 中。
然而在C#代码中这样写:
((Label)Repeater1.FindControl("lblCurrentPage")).Text = "test";可运行时就出了这样的一个错:未将对象引用设置到对象的实例。 NullReferenceException
经过检验是((Label)Repeater1.FindControl("lblCurrentPage")) 对象为空(Null)请问为什么FindControl查找不到FooterTemplate里的内容呢?
<asp:Label ID="lblCurrentPage" runat="server" Text="1"></asp:Label> 页 / 共 <asp:Label ID="lblPageCount" runat="server" Text="1"></asp:Label> 页
</FooterTemplate>我将两个标签放在 Repeater 控件的 FooterTemplate 中。
然而在C#代码中这样写:
((Label)Repeater1.FindControl("lblCurrentPage")).Text = "test";可运行时就出了这样的一个错:未将对象引用设置到对象的实例。 NullReferenceException
经过检验是((Label)Repeater1.FindControl("lblCurrentPage")) 对象为空(Null)请问为什么FindControl查找不到FooterTemplate里的内容呢?
解决方案 »
- 关于gridview隐藏列的问题
- 高分求如何在asp.net中将数据库中binary字段存储的rtf格式的带文本和图片的内容读取到ie中的方法,可以用控件,但不能用文件方式存储rtf
- 大哥大姐帮帮忙了,看看这个方法行得通么?
- 急问,vs2005页面设计器不能保存,只能切换到源代码里编辑才能保存,什么原因?
- Gridview导出EXECL2000多行表头问题
- ★ 请大家讲讲使用 Session 做身份验证的缺点以及怎样才能做好最好! ★
- 初学者问题,请大家帮帮忙,谢谢了!!
- 【Repeater控件的多行多列显示】
- MVC如何多层目录路由?地址栏也要多层目录对应,谢谢
- CrystalReport导出问题
- DATAGRID的换页问题
- 表的列名???
{
((Label)Repeater1.FindControl("lblCurrentPage")).Text = "test";
}
这样试试看。
{
Label pageno=(Label)e.Item.FindControl("lblCurrentPage"));
.....
}
在databound事件中。
{
if (e.Item.ItemType == ListItemType.Footer)
{
((Label)Repeater1.FindControl("lblCurrentPage")).Text = "test"; // 错误
}
}还是不性啊`!((Label)Repeater1.FindControl("lblCurrentPage")) 为 null