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

Object reference not set to an instance of an object.

P: n/a
Hello,

I have a user control that contains a datalist and within that a asp label,
as follows:

<asp:DataList ID="dlHomeDetail_Starters" Runat="server" CellPadding="1"
CellSpacing="1" Width="100%" RepeatDirection="Vertical" RepeatColumns="1">
<HeaderTemplate>
<tr class=mainhead vAlign=center>
<td class=away colSpan=5><asp:Label ID="lblGroupName"
Runat="server"></asp:Label></td>
</tr>
<tr class=bg1 align=middle>

In my code behind, in the page load event I am receiving this error "Object
reference not set to an instance of an object" on this line
lblGroupName.Text = "Test".

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

lblGroupName.Text = "Test"

dlHomeDetail_Starters.DataSource =
oFFLLeague.getPlayerStats_TeamSummary(Session("FFL LeagueID"),
Request.Params("week"),
oFFLLeague.getHomeTeamIDFromGameID(Request.Params( "week"),
Request.Params("gid")), "Starters")
dlHomeDetail_Starters.DataBind()

End Sub

Is my problem due to the sequence of events in the webform page load and
that the label is not yet available? I always find understanding the order
of events confusing when using a user control.

Any help is appreciated,
Thanks Chris
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Usually when you get the error it is because of a type
mismatch. But things that I see in your code are that you
seem to be calling databind without filling your dataset
with a data adapter?
-----Original Message-----
Hello,

I have a user control that contains a datalist and within that a asp label,as follows:

<asp:DataList ID="dlHomeDetail_Starters" Runat="server" CellPadding="1"CellSpacing="1" Width="100%" RepeatDirection="Vertical" RepeatColumns="1"> <HeaderTemplate>
<tr class=mainhead vAlign=center>
<td class=away colSpan=5><asp:Label ID="lblGroupName"
Runat="server"></asp:Label></td>
</tr>
<tr class=bg1 align=middle>

In my code behind, in the page load event I am receiving this error "Objectreference not set to an instance of an object" on this linelblGroupName.Text = "Test".

Private Sub Page_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

lblGroupName.Text = "Test"

dlHomeDetail_Starters.DataSource =
oFFLLeague.getPlayerStats_TeamSummary(Session ("FFLLeagueID"),Request.Params("week"),
oFFLLeague.getHomeTeamIDFromGameID(Request.Params ("week"),
Request.Params("gid")), "Starters")
dlHomeDetail_Starters.DataBind()

End Sub

Is my problem due to the sequence of events in the webform page load andthat the label is not yet available? I always find understanding the orderof events confusing when using a user control.

Any help is appreciated,
Thanks Chris
.

Nov 17 '05 #2

P: n/a
Your data-bound control results in multiple label
controls, not just one.

you need to go through the rows of the resulting control
to find the label you want, or use findControl or any
other number of ways to navigate the control structure.
-----Original Message-----
Hello,

I have a user control that contains a datalist and within that a asp label,as follows:

<asp:DataList ID="dlHomeDetail_Starters" Runat="server" CellPadding="1"CellSpacing="1" Width="100%" RepeatDirection="Vertical" RepeatColumns="1"> <HeaderTemplate>
<tr class=mainhead vAlign=center>
<td class=away colSpan=5><asp:Label ID="lblGroupName"
Runat="server"></asp:Label></td>
</tr>
<tr class=bg1 align=middle>

In my code behind, in the page load event I am receiving this error "Objectreference not set to an instance of an object" on this linelblGroupName.Text = "Test".

Private Sub Page_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

lblGroupName.Text = "Test"

dlHomeDetail_Starters.DataSource =
oFFLLeague.getPlayerStats_TeamSummary(Session ("FFLLeagueID"),Request.Params("week"),
oFFLLeague.getHomeTeamIDFromGameID(Request.Params ("week"),
Request.Params("gid")), "Starters")
dlHomeDetail_Starters.DataBind()

End Sub

Is my problem due to the sequence of events in the webform page load andthat the label is not yet available? I always find understanding the orderof events confusing when using a user control.

Any help is appreciated,
Thanks Chris
.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.