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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:10:57+00:00 2026-06-06T08:10:57+00:00

Possible Duplicate: Object reference not set to an instance of an object errors when

  • 0

Possible Duplicate:
Object reference not set to an instance of an object errors when using CreateUserWizard

The error – “Object reference not set to an instance of an object” occured when I hit the “Next’ button of my CreateUserWizard controls. I had checked through my codes that I did not leave any of my variables null. but i still can’t solve this errors.

This is the caused of the error:
Line 31: DataSource.InsertParameters.Add(“UserId”, UserGUID.ToString());

 Source Error: 

    Line 29:         object UserGUID = User.ProviderUserKey;
    Line 30: 
    Line 31:         DataSource.InsertParameters.Add("UserId", UserGUID.ToString()); 
    Line 32: 
    Line 33:         DataSource.Insert();

This is my html code file: 

 <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" 
            OnCreatedUser="CreateUserWizard1_CreatedUser" CreateUserButtonText="Next" 
            FinishCompleteButtonText="Create User" Height="330px" 
            Width="512px">
            <WizardSteps>

                <asp:CreateUserWizardStep ID="CreateUserWizardStep2" runat="server" >
                <ContentTemplate>
                    <table>
                        <tr>
                            <th>User Information</th>
                        </tr>
                        <tr>
                            <td>Username:</td>
                            <td class="style2">
                                <asp:TextBox runat="server" ID="UserName" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" 
                                    ErrorMessage="Username is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td class="style2">
                                <asp:TextBox runat="server" ID="Password" TextMode="Password" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" 
                                    ErrorMessage="Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Confirm Password:</td>
                            <td class="style2">
                                <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" 
                                    ErrorMessage="Confirm Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Email:</td>
                              <td class="style2">
                                <asp:TextBox runat="server" ID="Email" />
                                  <asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server" ControlToValidate="Email" 
                                      ErrorMessage="Email required."></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Question:</td>
                            <td class="style2">
                                <asp:TextBox runat="server" ID="Question" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" 
                                    ErrorMessage="Question is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>Answer:</td>
                            <td class="style2">
                                <asp:TextBox runat="server" ID="Answer" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" 
                                    ErrorMessage="Answer is required." />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                 <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                            </td>
                        </tr>
                    </table>


                </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:WizardStep ID="CreateUserWizardStep0" runat="server" Title="User Details">
                    <table>
                        <tr>
                            <th>Billing Information</th>
                        </tr>
                        <tr>
                            <td>Name:</td>
                            <td class="style1">
                                <asp:TextBox runat="server" ID="CustName" />
                                  <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator18" ControlToValidate="CustName"
                                     ErrorMessage="Name is required."  />
                                     </td>
                        </tr> 
                        <tr>
                            <td>Contact Number:</td>
                            <td class="style1">
                                <asp:TextBox runat="server" ID="CustNum"  />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator19" ControlToValidate="CustNum"
                                     ErrorMessage="Contact num is required."  />
                            </td>
                        </tr>   
                        <tr>
                            <td>Role:</td>
                            <td class="style1">
                                <asp:DropDownList ID="CustRole" runat="server" AutoPostBack="True" Height="16px" 
                                    Width="123px">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Bride</asp:ListItem>
                                    <asp:ListItem>Groom</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator20" ControlToValidate="CustRole"
                                     ErrorMessage="Role is required." />
                            </td>
                        </tr>                
                        <tr>
                            <td>
                                Status:</td>
                            <td class="style1">
                                <asp:DropDownList ID="CustStatus" runat="server" AutoPostBack="True" 
                                    Height="17px" Width="121px">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Status A</asp:ListItem>
                                    <asp:ListItem>Status B</asp:ListItem>
                                    <asp:ListItem>Status C</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server" ControlToValidate="CustStatus"
                                    ErrorMessage="Status is required."/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td class="style1">
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td>
                                Partner&#39;s Name:</td>
                              <td class="style1">
                                <asp:TextBox runat="server" ID="PName"  />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="PName"
                                     ErrorMessage="PName is required."  />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Partner Email:</td>
                            <td class="style1">
                                <asp:TextBox runat="server" ID="PEmail"  />

                            </td>
                        </tr>
                        <tr>
                            <td>
                                PRole:
                            </td>
                            <td class="style1">
                                <asp:DropDownList ID="PRole" runat="server" AutoPostBack="True" Height="16px" 
                                    Width="123px">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Bride</asp:ListItem>
                                    <asp:ListItem>Groom</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator7" ControlToValidate="PRole"
                                     ErrorMessage="PRole is required." />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Wed Date:
                            </td>
                            <td class="style1">
                                <cc1:DatePicker ID="WedDate" runat="server" CalendarDate="" 
                                    TextCssClass="" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server" ControlToValidate="WedDate"
                                    ErrorMessage="Wedding date required"/>
                            </td>
                        </tr>
                    </table>
                </asp:WizardStep>

                <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                    <ContentTemplate>
                        <table>
                            <tr>
                                <td align="center" colspan="2">
                                    Complete</td>
                            </tr>
                            <tr>
                                <td>
                                    Your account has been successfully created.</td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="ContinueButton" runat="server" CausesValidation="False" 
                                        CommandName="Continue" Text="Continue" ValidationGroup="CreateUserWizard1" />
                                </td>
                            </tr>
                        </table>


                       <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
                        InsertCommand="INSERT INTO [UserDetails] ([UserId], [CustName], [CustNum], [CustRole], [CustStatus], [PName], [PEmail], [PRole], [WedDate]) VALUES (@UserId, @CustName, @CustNum, @CustRole, @CustStatus, @PName, @PEmail, @PRole, @WedDate)"
                        ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString1.ProviderName %>">
                        <InsertParameters>
                            <asp:ControlParameter Name="CustName" Type="String" ControlID="CustName" PropertyName="Text" />
                            <asp:ControlParameter Name="CustNum" Type="String" ControlID="CustNum" PropertyName="Text" />
                            <asp:ControlParameter Name="CustRole" Type="String" ControlID="CustRole" PropertyName="Text" />
                            <asp:ControlParameter Name="CustStatus" Type="String" ControlID="CustStatus" PropertyName="Text" />
                            <asp:ControlParameter Name="PName" Type="String" ControlID="PName" PropertyName="Text" />
                            <asp:ControlParameter Name="PEmail" Type="String" ControlID="PEmail" PropertyName="Text" />
                            <asp:ControlParameter Name="PRole" Type="String" ControlID="PRole" PropertyName="Text" />
                            <asp:ControlParameter Name="WedDate" Type="String" ControlID="WedDate" PropertyName="Text" />
                        </InsertParameters>

                    </asp:SqlDataSource>

                    </ContentTemplate>
                </asp:CompleteWizardStep>
            </WizardSteps>

        </asp:CreateUserWizard>
        <br />
    </div>

This is the code behind: 

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web.Security;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class Register : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        TextBox UserName=
        (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");

        SqlDataSource DataSource =
        (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

       MembershipUser User = Membership.GetUser(UserName.Text);

        object UserGUID = User.ProviderUserKey;

        DataSource.InsertParameters.Add("UserId", UserGUID.ToString());  //the error lies at here

        DataSource.Insert();

    }
    }
  • 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-06T08:10:59+00:00Added an answer on June 6, 2026 at 8:10 am

    The InsertExtraInfo is actually inside CompleteWizardStep1. Try this:

    SqlDataSource DataSource =
        (SqlDataSource)CompleteWizardSetp1.ContentTemplateContainer
            .FindControl("InsertExtraInfo");
    

    But I believe you can use the outermost container CreateUserWizard1 so you don’t have to worry about which step it’s in.

    CreateUserWizard1.FindControl("InsertExtraInfo");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Passing an IDisposable object by reference causes an error? Why doesn't C#
Possible Duplicate: what happens to an object in Java if you do not reference
Possible Duplicate: Java: Rationale of the Object class not being declared abstract Why is
Possible Duplicate: Properties and Instance Variables in Objective-C 2.0 I'm using properties only for
Possible Duplicate: Is it possible to pass parameters by reference using call_user_func_array()? I have
Possible Duplicate: Self-references in object literal declarations Hey Guys, i have a small question
Possible Duplicate: is object empty? update: (id, data) -> toUpdate = @find(id) if toUpdate
Possible Duplicate: Comparing object properties in c# Let's say I have a POCO: public
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: How to determine an object's class (in Java)? Java determine which class

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.