Thursday, March 22, 2012

System.NullReferenceException: Object reference not set to an instance of an object.

Hi all,

I have the following peice of code:

Esssentially, a querystring containing a comma separated list of values is
used to populate the appropriate intSectionID property of a user control.

<% If Not(Request.QueryString("SectionID") Is Nothing) Then %
<% arrSectionID = Split(Request.QueryString("SectionID"), ",") %>
<Company:Links ID="LevelTwo" intSectionID="<%# arrSectionID(0) %>"
Runat="Server"/
<% End If %
However i keep gettting the error listed in my post..

Can someone fill me in on what could be going wrong?

I have a suspicion it may be occuring when the User Controls DataBind method
is called.
The variable is visible to the parent page, but not the user control??

Suggest a way to fix?

Cheers,
AdamAdam,
This is aspnet user group. <%# %> code is ASP. Yes a few things are still
used <% %> this is only available for backwards compatibility not new
development.
Use the page_load or Page_render events for processing the querry string
into your control.

Bad luck

"Adam Knight" wrote:

> Hi all,
> I have the following peice of code:
> Esssentially, a querystring containing a comma separated list of values is
> used to populate the appropriate intSectionID property of a user control.
> <% If Not(Request.QueryString("SectionID") Is Nothing) Then %>
> <% arrSectionID = Split(Request.QueryString("SectionID"), ",") %>
> <Company:Links ID="LevelTwo" intSectionID="<%# arrSectionID(0) %>"
> Runat="Server"/>
> <% End If %>
> However i keep gettting the error listed in my post..
> Can someone fill me in on what could be going wrong?
> I have a suspicion it may be occuring when the User Controls DataBind method
> is called.
> The variable is visible to the parent page, but not the user control??
> Suggest a way to fix?
> Cheers,
> Adam
>

0 comments:

Post a Comment