在数据列表中找到控件时出错 [英] Error in finding control in datalist
本文介绍了在数据列表中找到控件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友
我收到了
的错误
对象引用未设置为对象的实例.
我正在使用此代码
Hello Friends
i am getting an error of
Object reference not set to an instance of an object.
I am using this code
var tv = sender as TreeView;
var dataListItem = tv.NamingContainer as DataListItem;
Panel pnl1 = (Panel)dataListItem.FindControl("pnlComments");
请帮忙
Kindly Help
推荐答案
原因可能是tv.NamingContainer
是null
.
在行上放置break point
The reason may be thattv.NamingContainer
isnull
.
Put abreak point
on the line
Panel pnl1 = (Panel)dataListItem.FindControl("pnlComments");
运行程序,并在断点处停止执行时,检查tv.NamingContainer
是否为null
.如果是这样,请检查该代码以获取非null值.
run the program and when the execution stops at the break point, check whether tv.NamingContainer
is null
. If so take check that code to get non null value.
这篇关于在数据列表中找到控件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文