NullReferenceException when trying to access control from property

X

xazos79

Hi All,
I've scoured the web for an answer to this to no avail.

I've developed a dual list control that has a few standard controls on
it (2 list boxes, some buttons etc).

I've defined the following property on the user control:

[Description("The field in the data source which provides the item
text."),
Category("Data"),
DefaultValue(DATA_TEXT_FIELD_DEFAULT)]
public string DataTextField
{
get { return m_dataTextField; }
set
{
m_dataTextField = value;
lstAvailable.DataTextField = m_dataTextField;
}
}

If i leave the property as default all is fine, however, if i set the
property like so:
<UC:DualListBox ID="dlRolesDualListBox" runat="server"
DataTextField="RoleName"/>

I get a NullReferenceException in the set accessor method for the
lstAvailable control. Can anyone offer any reasons why lstAvailable
(listbox) hasn't been initialized ?

Cheers for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top