473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

repeater inside a repeater problem.

Hello everyone,
I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me that my second repeater has the following error, System.NullReferenceException: Object reference not set to an instance of an object.

When I put a watch on I can see my second repeater is not being created because it is equal to "Nothing". I can tell that this is not creating the object properly but I don't understand why. Before I paste my code I want to explain the process I am trying to do so the code is more understandable. The first repeater on my page pulls the duties that are available from a table using a stored procedure, the second repeater process is supposed to create the sub duties that are linked to a categorey of duties. The code gets all the way to building the bind child sub-duties process to the part where it is supposed to populate the repeater but it tells me the error and the repeater is "Nothing".
Notice that the line Protected WithEvents drptrDIVConstRollsChild As System.Web.UI.WebControls.Repeater
exists in my backend and that the repeater is called the same inside the other repeater.
My code is as follows and thanks in advance for your help.
Mike

--------ASP Page for front end--------

<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="PhoneListInfo.aspx.vb" Inherits="D4ConstWeb.PhoneListInfo" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Phone List Info</title>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<LINK href="./style/DIVStyle.css" type="text/css" rel="stylesheet">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body>
<table cellpadding=0 cellspacing=0>
<asp:Repeater id="drptrDIVConstRollsParent" runat="server">
<ItemTemplate>
<tr class="Header">
<td><%# DataBinder.Eval(container.dataitem, "Duty") %></td>
<td>
Primary
</td>
<td>
Secondary
</td>
</TR>
<asp:Repeater ID="drptrDIVConstRollsChild" Runat="server" DataSource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'>
<ItemTemplate>
<tr Class="OddItem">
<td>&nbsp;<%# DataBinder.Eval(container.dataitem, "SubDutyType") %></td>
<td><a href="mailto:<%# DataBinder.Eval(container.dataitem, "PrimeEmail") %>"><%# DataBinder.Eval(container.dataitem, "Prime") %></a></td>
<td><a href="mailto:<%# DataBinder.Eval(container.dataitem, "SecondEmail") %>"><%# DataBinder.Eval(container.dataitem, "Secondary") %></a><%# DataBinder.Eval(container.dataitem, "Seperator") %><a href="mailto:<%# DataBinder.Eval(container.dataitem, "SubSecondEmail") %>"><%# DataBinder.Eval(container.dataitem, "SubSecondary") %></a></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr Class="EvenItem">
<td>&nbsp;<%# DataBinder.Eval(container.dataitem, "SubDutyType") %></td>
<td><a href="mailto:<%# DataBinder.Eval(container.dataitem, "PrimeEmail") %>"><%# DataBinder.Eval(container.dataitem, "Prime") %></a></td>
<td><a href="mailto:<%# DataBinder.Eval(container.dataitem, "SecondEmail") %>"><%# DataBinder.Eval(container.dataitem, "Secondary") %></a><%# DataBinder.Eval(container.dataitem, "Seperator") %><a href="mailto:<%# DataBinder.Eval(container.dataitem, "SubSecondEmail") %>"><%# DataBinder.Eval(container.dataitem, "SubSecondary") %></a></td>
</tr>
</AlternatingItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</table>
</body>
</HTML>


------ASP Page for Back end--------

Imports System.Data
Imports System.Data.SqlClient

Public Class PhoneListInfo
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents drptrDIVConst As System.Web.UI.WebControls.Repeater
Protected WithEvents drptrDIVConstRollsParent As System.Web.UI.WebControls.Repeater
Protected WithEvents drptrDIVConstRollsChild As System.Web.UI.WebControls.Repeater

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Public DS As New DataSet

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
BindData("strDIVConstEmp", "GetDIVContEmp", 1, 0)
BindDataParent("Duties", "GetAllDuties", 1)
BindDataChild("SubDuties", "GetAllSubDuties", "Duties", "DutyID", 1)
End Sub

#Region " Bind Parent Duties "
Sub BindDataParent(ByVal TableName As String, ByVal CommandText As String, ByVal Office As Integer)
Dim SqlConn As New SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim sqlAdapter As New SqlDataAdapter

sqlAdapter.SelectCommand = New SqlCommand
With sqlAdapter.SelectCommand
.Connection = SqlConn
.CommandType = CommandType.StoredProcedure
End With

Dim OfficeID As New SqlParameter("@OfficeId", SqlDbType.BigInt)

'Parameters
OfficeID.Value = Office 'District IV Excutives Offices

With sqlAdapter.SelectCommand
.CommandText = CommandText
.Parameters.Add(OfficeID)
End With

sqlAdapter.Fill(DS, TableName)

With drptrDIVConstRollsParent
.DataSource = DS.Tables(TableName)
End With
Page.DataBind()

SqlConn.Close()

End Sub

#End Region

#Region " Bind Child Sub-Duties "
Sub BindDataChild(ByVal TableNameChild As String, ByVal CommandText As String, ByVal TableNameParent As String, ByVal BindField As String, ByVal Office As Integer)
Dim SqlConn As New SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim sqlAdapter As New SqlDataAdapter

sqlAdapter.SelectCommand = New SqlCommand
With sqlAdapter.SelectCommand
.Connection = SqlConn
.CommandType = CommandType.StoredProcedure
End With

Dim OfficeID As New SqlParameter("@OfficeId", SqlDbType.BigInt)

'Parameters
OfficeID.Value = Office 'District IV Excutives Offices

With sqlAdapter.SelectCommand
.CommandText = CommandText
.Parameters.Add(OfficeID)
End With

sqlAdapter.Fill(DS, TableNameChild)

'Additional Parameters
DS.Relations.Add("myrelation", _
DS.Tables(TableNameParent).Columns(BindField), _
DS.Tables(TableNameChild).Columns(BindField))

With drptrDIVConstRollsChild
.DataSource = DS.Tables(TableNameParent)
End With
Page.DataBind()

SqlConn.Close()

End Sub
#End Region

End Class
Oct 25 '06 #1
0 4073

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
3
by: Leigh Webber | last post by:
I have an HTMLAnchor control on my aspx page. When it's not inside a repeater, it works fine. When I put it inside a repeater control, the handler never gets fired. I have a handler for the...
0
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
0
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater)....
1
by: smash2004 | last post by:
I have VS 2005 CTP. I created a page with one repeater. Inside i put a linkbutton. Usually when i put linkbutton on a page I doubleclick it in designview and event gets created in codebehind...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
2
by: Hong | last post by:
Hi, I have been scratching my head over this problem for hours, the repeater control I am using would only render the controls specified in HeaderTemplate and FooterTemplate, but the repeater...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.