Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6199897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:16:18+00:00 2026-05-24T04:16:18+00:00

I am taking some code that I have used for a nested listview before

  • 0

I am taking some code that I have used for a nested listview before and trying to make it work with a nested Repeater but I am getting an error.

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

.aspx

    <asp:Repeater ID="reMainNav" runat="server">
    <HeaderTemplate><ul></HeaderTemplate>
    <ItemTemplate><li><%# DataBinder.Eval(Container.DataItem, "name")%>

        <asp:Repeater ID="reSubNav" runat="server">
            <HeaderTemplate>
                <ul>
            </HeaderTemplate>
            <ItemTemplate>
                <li>
                    <%# DataBinder.Eval(Container.DataItem, "name")%>
                </li>
            </ItemTemplate>
            <FooterTemplate>
                </ul>
            </FooterTemplate>
        </asp:Repeater>

    </li></ItemTemplate>
    <FooterTemplate></ul></FooterTemplate>
</asp:Repeater>

.vb

    Protected Sub reMainNav_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles reMainNav.ItemDataBound

    Dim rowView As System.Data.DataRowView
    rowView = CType(e.Item.DataItem, System.Data.DataRowView)

    'database connection from web.config file
    Dim synergySQL As SqlConnection = New SqlConnection()
    synergySQL.ConnectionString = ConfigurationManager.ConnectionStrings("connSynergy").ConnectionString()

    'check if personal section complete
    Dim cmdSubNav As SqlCommand = New SqlCommand()
    cmdSubNav.Connection = synergySQL
    cmdSubNav.CommandText = "SELECT * FROM [subNavigation] WHERE [parentId] = " & rowView("id") & " ORDER BY [orderNo]"
    cmdSubNav.CommandType = CommandType.Text
    'data adapter
    Dim daSubNav As SqlDataAdapter = New SqlDataAdapter
    daSubNav.SelectCommand = cmdSubNav
    'data set
    Dim dsSubNav As DataSet = New DataSet()
    daSubNav.Fill(dsSubNav, "SubNav")

    Dim iSchedule As Integer
    iSchedule = dsSubNav.Tables(0).Rows.Count

    Dim reSubNav As Repeater = CType(e.Item.FindControl("reSubNav"), Repeater)
    reSubNav.DataSource = dsSubNav
    reSubNav.DataBind()

    synergySQL.Close()

End Sub

Do i have to do something different for a repeater?

Thanks for any help.

J.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:16:19+00:00Added an answer on May 24, 2026 at 4:16 am

    Its header row for first time so you are unable to get the inner repeater control. Apply check for item type as below.

    Protected Sub reMainNav_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles reMainNav.ItemDataBound
    
     If e.Item.ItemType == ListItemType.Item OrElse e.Item.ItemType == ListItemType.AlternatingItem Then
    
        Dim rowView As System.Data.DataRowView
        rowView = CType(e.Item.DataItem, System.Data.DataRowView)
    
        'database connection from web.config file
        Dim synergySQL As SqlConnection = New SqlConnection()
        synergySQL.ConnectionString = ConfigurationManager.ConnectionStrings("connSynergy").ConnectionString()
    
        'check if personal section complete
        Dim cmdSubNav As SqlCommand = New SqlCommand()
        cmdSubNav.Connection = synergySQL
        cmdSubNav.CommandText = "SELECT * FROM [subNavigation] WHERE [parentId] = " & rowView("id") & " ORDER BY [orderNo]"
        cmdSubNav.CommandType = CommandType.Text
        'data adapter
        Dim daSubNav As SqlDataAdapter = New SqlDataAdapter
        daSubNav.SelectCommand = cmdSubNav
        'data set
        Dim dsSubNav As DataSet = New DataSet()
        daSubNav.Fill(dsSubNav, "SubNav")
    
        Dim iSchedule As Integer
        iSchedule = dsSubNav.Tables(0).Rows.Count
    
        Dim reSubNav As Repeater = CType(e.Item.FindControl("reSubNav"), Repeater)
        reSubNav.DataSource = dsSubNav
        reSubNav.DataBind()
    
        synergySQL.Close()
    
    End If
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Taking over some code from my predecessor and I found a query that uses
I was taking a look through some open-source C++ code and I noticed a
I am interested in getting some Python code talking to some Ruby code on
I have a project where I am taking some particularly ugly live HTML and
We have some issues in our application with skype taking over some of our
I have some code I developed in python 2.4++ and you bet, I have
I'm a bit of a NHibernate newbie and Im taking on some code written
I've been taking a look at some different products for .NET which propose to
I am using MS reporting services and some of the reports are taking longer
I am taking a principles of programming languages course right now but I cannot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.