Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object reference not set to an instance of an object.
Message
From
13/03/2010 11:00:47
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01454270
Message ID:
01454303
Views:
35
>I have tried moving the instantiations into _LoadList, and it still fails. DataLayer is an object. dsRoles is null. When I run the
>ExecuteQuery line it errors.


I don't see how dsRoles can be null and DataLayer is not. They are both instantiated in the same place. Are you certain that they're not both null?

As to *where* they should be instantiated, I have no idea, since this is a web page and I don't remember much about when events fire in web stuff.

~~Bonnie



>What's wrong with this?
>
>
>public partial class crlRoles : System.Web.UI.UserControl
>{
>    private DataSet dsRoles = null;
>    private DataAccess DataLayer = null;
>
>    protected void Page_Load(object sender, EventArgs e)
>    {
>        if (!IsPostBack)
>        {
>            dsRoles = new DataSet();
>            DataLayer = new DataAccess();
>            DataLayer.ConnectionString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
>
>            _LoadList();
>        }
>    }
>
>    private void _LoadList()
>    {
>
>        dsRoles = DataLayer.ExecuteQuery("as_GetRole", CommandType.StoredProcedure);
>
>        lstRoles.DataSource = dsRoles.Tables[0];
>        lstRoles.DataMember = "RoleName";
>    }
>}
>
>
>I have tried moving the instantiations into _LoadList, and it still fails. DataLayer is an object. dsRoles is null. When I run the
>ExecuteQuery line it errors.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform