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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:29:15+00:00 2026-06-16T00:29:15+00:00

For some reason, all of the objects in my ASP.NET markup are now null

  • 0

For some reason, all of the objects in my ASP.NET markup are now null when I try to assign values to their properties in the code behind.

My project was going fine and then now when I try to assign a data source to a GridView, I get a null reference error.

I have no idea why it’s doing this. I am not doing nothing special. I am just trying to assign a value to a property to an asp.net element in on the page. The intellisense knows that the element is there and I get no errors when I build the project. It’s just when I am running the website I get the null reference.

I have been trying to fix this issue for a couple weeks now. Please Help.

Thanks.

Here is the code:

protected void Page_PreRender(object sender, EventArgs e)
{
    LoadData();
}

private void LoadData()
{
    Entities context = new Entities();
    var types = (from t in context.CustomerTypes
                 select t).OrderBy(t => t.TypeName);

    gvCustomerTypes.DataSource = types;
    gvCustomerTypes.DataBind();

}

and on in the markup the gridview looks like this:

<asp:GridView ID="gvCustomerTypes" runat="server" ShowHeader="true" GridLines="Both"
    AutoGenerateColumns="false" AlternatingRowStyle-BackColor="AliceBlue" Width="100%">
    <Columns>
        <asp:TemplateField HeaderText="Customer Type Name" HeaderStyle-HorizontalAlign="Left"
            ItemStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <asp:Label ID="lblType" runat="server" Text='<%# Eval("TypeName") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
            <ItemTemplate>
                <asp:HyperLink ID="HyperLink1" NavigateUrl='<%#Eval("CustomerTypeID", "CreateEditCustomerType.aspx?ID={0}") %>'
                    Text="Edit" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Delete" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" CommandName='<%#Eval("CustomerTypeID") %>' OnClientClick="javascript:return confirm('Are you sure you want to delete this Customer Type?');"
                    OnCommand="DeleteCustomerType" Text="Delete" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
  • 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-16T00:29:16+00:00Added an answer on June 16, 2026 at 12:29 am

    I solved this issue!! YAY!

    I had a master page with a LoginView control.

    In the loggedin view of the LoginView control is where I put the content place holder for pages that use that master page. So all the controls were return null because of the loggedin view template for the LoginView control.

    I am not completely sure why this does this but at least I found out my null reference problem.

    Hope this saves someone else a headache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, when I try to run this code, all I get is
For some reason duplicate values aren't eliminated. records = Records.objects.all() records2 = records.values_list('columna','columna').distinct() print
How do I get the collection of all Session objects in ASP.NET? (Note that
For some reason, any CalendarExtenders on an ASP.NET site that is being worked on
For some reason i can't get the variable 'total' to define at all... I
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
for some reason when I try to call CocoaAsyncSocket's onSocket:didReadData:withTag method, it's failing and
For some reason, the Google API expects longs instead of objects (like Color). What
I have built an ASP.NET MVC app some time ago, and after a few
I'm new to ASP.NET but have quite a few successful test pages going now

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.