By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

Repeater control in a web user control

P: n/a
I have a Repeater control in a web user control.

The web user control has a public method named PopulateRepeater which takes
an ID as an parameter and populates the repeater control based on the
parameter.

When I call PopulateRepeater from the User Control page_load event it
populates the repeater without a problem.

When I call PopulateRepeater from a procedure in the web form which contains
the user control, I get an error in PopulateReader (which is in the User
Control code behind module):

Sub PopulateRepeater (iID as integer)
dim ds as DataSet = GetDataSet(iID)
Repeater1.DataSource = ds ' causes error "Object reference not set
to an instance of an object"
Repeater1.DataBind
Exit Sub

Apr 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Apparently, the method called is not returning a DataSet.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
I have a Repeater control in a web user control.

The web user control has a public method named PopulateRepeater which
takes an ID as an parameter and populates the repeater control based on
the parameter.

When I call PopulateRepeater from the User Control page_load event it
populates the repeater without a problem.

When I call PopulateRepeater from a procedure in the web form which
contains the user control, I get an error in PopulateReader (which is in
the User Control code behind module):

Sub PopulateRepeater (iID as integer)
dim ds as DataSet = GetDataSet(iID)
Repeater1.DataSource = ds ' causes error "Object reference not set
to an instance of an object"
Repeater1.DataBind
Exit Sub


Apr 5 '06 #2

P: n/a
It's not the dataset, its the Repeater which is 'nothing'.

I found the reason - the way a web user control is declared is different in
VS2005 than VS2003, I guess because of the partial class structure of the
web forms..

In VS2005, I find you just go ahead and call the user control directly using
its ID -- without creating an object variable--in order to call it's methods
from the host code behind:
ucUserControl1.PopulateRepeater

In VS 2003, the user control first had to be declared in the host code
behind in order to call its methods:
Protected ucUserControl1 as New ucUserControl

If you do this in VS2005, you get an error
"ucUserControl1 already declared as... in this class"
so I was using
dim ucUserControl1 as new ucUserControl
and getting the "Object reference not set to an instance of an object"
error.

I'm still getting used to partial classes.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OT**************@TK2MSFTNGP05.phx.gbl...
Apparently, the method called is not returning a DataSet.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
I have a Repeater control in a web user control.

The web user control has a public method named PopulateRepeater which
takes an ID as an parameter and populates the repeater control based on
the parameter.

When I call PopulateRepeater from the User Control page_load event it
populates the repeater without a problem.

When I call PopulateRepeater from a procedure in the web form which
contains the user control, I get an error in PopulateReader (which is in
the User Control code behind module):

Sub PopulateRepeater (iID as integer)
dim ds as DataSet = GetDataSet(iID)
Repeater1.DataSource = ds ' causes error "Object reference not
set to an instance of an object"
Repeater1.DataBind
Exit Sub



Apr 5 '06 #3

P: n/a
Glad you got it sorted out!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:u5*************@TK2MSFTNGP04.phx.gbl...
It's not the dataset, its the Repeater which is 'nothing'.

I found the reason - the way a web user control is declared is different
in VS2005 than VS2003, I guess because of the partial class structure of
the web forms..

In VS2005, I find you just go ahead and call the user control directly
using its ID -- without creating an object variable--in order to call it's
methods from the host code behind:
ucUserControl1.PopulateRepeater

In VS 2003, the user control first had to be declared in the host code
behind in order to call its methods:
Protected ucUserControl1 as New ucUserControl

If you do this in VS2005, you get an error
"ucUserControl1 already declared as... in this class"
so I was using
dim ucUserControl1 as new ucUserControl
and getting the "Object reference not set to an instance of an object"
error.

I'm still getting used to partial classes.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OT**************@TK2MSFTNGP05.phx.gbl...
Apparently, the method called is not returning a DataSet.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
I have a Repeater control in a web user control.

The web user control has a public method named PopulateRepeater which
takes an ID as an parameter and populates the repeater control based on
the parameter.

When I call PopulateRepeater from the User Control page_load event it
populates the repeater without a problem.

When I call PopulateRepeater from a procedure in the web form which
contains the user control, I get an error in PopulateReader (which is in
the User Control code behind module):

Sub PopulateRepeater (iID as integer)
dim ds as DataSet = GetDataSet(iID)
Repeater1.DataSource = ds ' causes error "Object reference not
set to an instance of an object"
Repeater1.DataBind
Exit Sub




Apr 5 '06 #4

P: n/a
Thanks!

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Os**************@TK2MSFTNGP04.phx.gbl...
Glad you got it sorted out!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:u5*************@TK2MSFTNGP04.phx.gbl...
It's not the dataset, its the Repeater which is 'nothing'.

I found the reason - the way a web user control is declared is different
in VS2005 than VS2003, I guess because of the partial class structure of
the web forms..

In VS2005, I find you just go ahead and call the user control directly
using its ID -- without creating an object variable--in order to call
it's methods from the host code behind:
ucUserControl1.PopulateRepeater

In VS 2003, the user control first had to be declared in the host code
behind in order to call its methods:
Protected ucUserControl1 as New ucUserControl

If you do this in VS2005, you get an error
"ucUserControl1 already declared as... in this class"
so I was using
dim ucUserControl1 as new ucUserControl
and getting the "Object reference not set to an instance of an object"
error.

I'm still getting used to partial classes.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OT**************@TK2MSFTNGP05.phx.gbl...
Apparently, the method called is not returning a DataSet.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"bill" <be****@datamti.com> wrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
I have a Repeater control in a web user control.

The web user control has a public method named PopulateRepeater which
takes an ID as an parameter and populates the repeater control based on
the parameter.

When I call PopulateRepeater from the User Control page_load event it
populates the repeater without a problem.

When I call PopulateRepeater from a procedure in the web form which
contains the user control, I get an error in PopulateReader (which is
in the User Control code behind module):

Sub PopulateRepeater (iID as integer)
dim ds as DataSet = GetDataSet(iID)
Repeater1.DataSource = ds ' causes error "Object reference not
set to an instance of an object"
Repeater1.DataBind
Exit Sub




Apr 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.