MultiSelectDropDown:用户控件:对象引用问题 [英] MultiSelectDropDown :user control : object reference problem
本文介绍了MultiSelectDropDown:用户控件:对象引用问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用用户控件进行多个下拉选择
Hi,
I am using the user control for multiple dropdown selection
protected void Page_Load(object sender, EventArgs e)
{
MultiSelectDropDown1.Clear(); //Error
MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem(new System.Web.UI.WebControls.ListItem("Apple", "1"));
MultiSelectDropDown1.List.Items.Add(new System.Web.UI.WebControls.ListItem("Grapes", "2"));
}
But getting exception at the first line itself.
Error:- Object reference not set to an instance of an object.
Please provide me the solution for this problem.
Thanks in advance.
推荐答案
问题很明显,如果您不这样做的话"不知道它是什么,您不应该编写代码.尝试阅读入门书籍,学习使用调试器,然后从那里开始工作. MultiSelectDropDown1不仅被愚蠢地命名,而且它为null,因此显然没有为其分配值,这使我想知道它的来源,显然不是aspx.
Your problem is so obvious, if you don''t know what it is, you should not be writing code. Try reading a beginner book, learn to use the debugger, and then work from there. MultiSelectDropDown1 is not only stupidly named, it is null, so it''s obviously not been assigned a value, which makes me wonder where it comes from, obviously not the aspx.
用户控件注册为:-
]]>
========================
并用作:-
< asp:content id ="Content2" contentplaceholderid ="ContentPlaceHolder1" runat ="Server" xmlns:asp =#unknown">
< cc2:multiselectdropdown id ="MultiSelectDropDown1" runat ="server" xmlns:cc2 =#unknown">
User control is Registered as :-
]]>
==========================
And used as :-
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="Server" xmlns:asp="#unknown">
<cc2:multiselectdropdown id="MultiSelectDropDown1" runat="server" xmlns:cc2="#unknown">
这篇关于MultiSelectDropDown:用户控件:对象引用问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文