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 8075969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:09:56+00:00 2026-06-05T15:09:56+00:00

I have a Master Page with nested pages in ASP.NET. Fairly simply I want

  • 0

I have a Master Page with nested pages in ASP.NET. Fairly simply I want to databind some hyperlinks to a gridview for the master page. This however is throwing a null reference exception when I try to set the DataSource.

  1. I tested the code on a separate page and it works as expected.
  2. When debugging I can see the Page_Load Sub hit twice, I don’t know if this is the cause
  3. I have one nested page being loaded, this is a blank page at the moment

EXCEPTION

Object reference not set to an instance of an object.

enter image description here

MASTERPAGE CODE BEHIND

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not Page.IsPostBack Then
        Using model = New AccessDataModelDataContext
            Dim result = From x In model.SiteLinks
                         Where x.IsActive
                         Select x

            SiteLinks.DataSource = result
            SiteLinks.DataBind()
        End Using
    End If

End Sub

MASTERPAGE ASPX CODE

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site.master.vb" Inherits="Access.Manager.Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="~/Styles/Styles.css" rel="stylesheet" type="text/css" />
    <title></title>

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Site.Master
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        <div class="navigation">
            Site Links
            <asp:GridView ID="SiteLinks" runat="server">
            </asp:GridView>
            </div>

        <div class="content">Site Content</div>


        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>
  • 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-06-05T15:09:57+00:00Added an answer on June 5, 2026 at 3:09 pm

    One glaring issue that I see, and could be your problem, is that your GridView exists inside of your content placeholder. Generally, those placeholders are for pages to implement, not the masterpage itself.

    Move the contents of the place holder out of it:

    <body>
        <form id="form1" runat="server">
        <div>
            Site.Master
            <div class="navigation">
                Site Links
                <asp:GridView ID="SiteLinks" runat="server">
                </asp:GridView>
            </div>
            <div class="content">Site Content</div>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use asp.net 4 and C#. I have some nested Master Pages; I display
I have 2 master pages that are nested.this is main master page code for
I have master page in asp.net.i want to display user in master page but
I have one master page which applies to all pages in this website. On
I have a master page in my asp.net MVC project, which has code like
I have a series of nested master pages, like so: site.master: <asp:ContentPlaceHolder ID=SearchFormContent runat=server>
I'm unable to set the tab title of my ASP.NET pages. I have nested
On an ASP.NET 4.0 website I am working on I have a master page
I'm creating an ASP.NET site where some pages need to have a div floated
I have created a vertical menu on a ASP.NET master page using jQuery. Here

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.