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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:07:00+00:00 2026-05-20T05:07:00+00:00

I am trying to update a user information and get the following error: Object

  • 0

I am trying to update a user information and get the following error:

Object reference not set to an
instance of an object. Description: An
unhandled exception occurred during
the execution of the current web
request. Please review the stack trace
for more information about the error
and where it originated in the code.

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

Source Error:

Line 20: ‘parameterless
constructor Line 21: Line 22:
user.Email =
DirectCast(e.NewValues(0), String)
Line 23: user.Comment =
DirectCast(e.NewValues(1), String)
Line 24: user.IsApproved =
CBool(e.NewValues(2))

The .vb code is:

Protected Sub UserInfo_ItemUpdating(ByVal sender As Object, ByVal e As DetailsViewUpdateEventArgs)
        'Need to handle the update manually because MembershipUser does not have a
        'parameterless constructor  

        user.Email = DirectCast(e.NewValues(0), String)
        user.Comment = DirectCast(e.NewValues(1), String)
        user.IsApproved = CBool(e.NewValues(2))

        Try
            ' Update user info:
            Membership.UpdateUser(user)

            ' Update user roles:
            UpdateUserRoles()

            UserUpdateMessage.Text = "Update Successful."

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        Catch ex As Exception
            UserUpdateMessage.Text = "Update Failed: " + ex.Message

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        End Try
    End Sub

Below is the .aspx code for the detailView:

 Protected Sub UserInfo_ItemUpdating(ByVal sender As Object, ByVal e As DetailsViewUpdateEventArgs)
        'Need to handle the update manually because MembershipUser does not have a
        'parameterless constructor  

        user.Email = DirectCast(e.NewValues(0), String)
        user.Comment = DirectCast(e.NewValues(1), String)
        user.IsApproved = CBool(e.NewValues(2))

        Try
            ' Update user info:
            Membership.UpdateUser(user)

            ' Update user roles:
            UpdateUserRoles()

            UserUpdateMessage.Text = "Update Successful."

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        Catch ex As Exception
            UserUpdateMessage.Text = "Update Failed: " + ex.Message

            e.Cancel = True
            UserInfo.ChangeMode(DetailsViewMode.[ReadOnly])
        End Try
    End Sub

Any idea how i can sort this?

Any help would be greatly appreciated.

Thanks

  • 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-20T05:07:01+00:00Added an answer on May 20, 2026 at 5:07 am

    My first guess, without seeing more code, would be that your user variable is null. Did you set it when you rendered the page? I assume your code above is a postback and so user lost it’s value.

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

Sidebar

Related Questions

I'm trying to update a hashtable in a loop but getting an error: System.InvalidOperationException:
I got this error when trying to update an image. It was a cross-thread
I am getting a strange exception when trying to update a DataTable after flagging
Trying to do an insert, I have: jdbcTemplate.update(insert into...., new Object[]{foo.getId(), foo.getName()}) foo.getId() returns
Recently, my Eclipse 3.4 installation started complaining while trying to update installed software. I
I'm trying to safely update the home directory as specified in /etc/passwd , but
I'm trying to do a simple update. I've done this kind of thing thousands
I'm trying to do the classic Insert/Update scenario where I need to update existing
I'm trying to run an update query that updates one table based on rows
I'm trying to display an update progress loading image whenever my update panel does

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.