Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 27th, 2012, 12:20 AM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default Object reference not set to an instance of an object.

Hi everyone. I usually know how to solve this error but this time I am getting really frustrated.

I added a dropdownlist to the createNewUser wizard and I want to get at the selected value becuase it selects an existing role and I want to add the user to it. The problem is I am getting this error when I try to use the dropdownlist that I grabbed from the FindControl method.

Any idea why it says that?

HTML Code:
 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
      // get dropdown list from createNewUser control and add user to dept role that was selected
      DropDownList DropDownListDept = (DropDownList)CreateUserWizard1.FindControl("DropDownListDept");
        
      // just to test it but it produces and object not to instance error!!! 
      lbl1.Text = DropDownListDept.SelectedItem.Text;
       
      Roles.AddUserToRole(CreateUserWizard1.UserName, DropDownListDept.SelectedItem.Text);
  }





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 14 - pg 517 - Item 9 (Object reference not set to an instance of an object. ) jkoyle BOOK: Beginning ASP.NET 4 : in C# and VB 5 August 25th, 2011 08:50 AM
Getting Error: Object reference not set to an instance of an object. oruckenan BOOK: Beginning ASP.NET 4 : in C# and VB 2 August 23rd, 2011 02:18 PM
Error - Object reference not set to an instance of an object Phil Critchley ASP.NET 4 General Discussion 2 April 30th, 2011 05:18 AM
Object reference not set to an instance of an object. Michael YoeH ASP.NET 3.5 Professionals 5 August 23rd, 2009 02:07 PM
Chap 13 pg448: Object reference not set to an instance of an object tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 15 August 8th, 2009 06:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.