473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Null Referance Exception

I keep getting the following exception 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 215: clubdg.DataBind();
Line 216:
Line 217: concat.DataSource=dsclub;
Line 218: concat.DataMember=dsclub.Tables["ConCat"].ToString();
Line
219: concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();
Source File: c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs Line: 217

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Sonar3.Secured.UserGrid.BindData() in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :217
Sonar3.Secured.UserGrid.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :67
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

This error is refering to the following Code Behind:

protected System.Web.UI.WebControls.DropDownList concat;
protected System.Web.UI.WebControls.DataGrid clubdg;
string strclubconn=ConfigurationSettings.AppSettings["ConnectionString"];
protected System.Web.UI.WebControls.HyperLink HyperLink1;
string userselect="SELECT User_tbl.*, ConCat.* FROM User_tbl, ConCat WHERE
User_tbl.concat=Concat.ContactID ORDER BY UserID Desc";
string strConCat="SELECT ConCat.* FROM ConCat";

public void BindData()
{
dsclub=new DataSet();
clubconn=new SqlConnection(strclubconn);
clubconn.Open();
clubadapt=new SqlDataAdapter(userselect,clubconn);
clubadapt.Fill(dsclub,"UserTbl");
clubadapt.SelectCommand=new SqlCommand(strConCat,clubconn);
clubadapt.Fill(dsclub,"ConCat");
clubconn.Close();

clubdg.DataSource=dsclub;
clubdg.DataMember=dsclub.Tables["UserTbl"].ToString();
clubdg.DataBind();

concat.DataSource=dsclub;
concat.DataMember=dsclub.Tables["ConCat"].ToString();
concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();
concat.DataValueField=dsclub.Tables["ConCat"].Columns["ContactID"].ToString();
concat.DataBind();
}
This is the Front End DropDownList control: the error is refering to:

<asp:DropDownList ID="concat" Runat="server"></asp:DropDownList>

I don't know where the null referance is if any one can tell me what the
problem is I'd greatly appreciate it.

Sam I am-

Nov 19 '05 #1
2 1533
'concat' is not an object. It is null.

Most likely the .aspx does not declare it correctly, so it is null on the
server.

"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
I keep getting the following exception 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 215: clubdg.DataBind();
Line 216:
Line 217: concat.DataSource=dsclub;
Line 218: concat.DataMember=dsclub.Tables["ConCat"].ToString();
Line
219:
concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();
Source File: c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs Line:
217

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Sonar3.Secured.UserGrid.BindData() in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :217
Sonar3.Secured.UserGrid.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :67
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

This error is refering to the following Code Behind:

protected System.Web.UI.WebControls.DropDownList concat;
protected System.Web.UI.WebControls.DataGrid clubdg;
string strclubconn=ConfigurationSettings.AppSettings["ConnectionString"];
protected System.Web.UI.WebControls.HyperLink HyperLink1;
string userselect="SELECT User_tbl.*, ConCat.* FROM User_tbl, ConCat WHERE
User_tbl.concat=Concat.ContactID ORDER BY UserID Desc";
string strConCat="SELECT ConCat.* FROM ConCat";

public void BindData()
{
dsclub=new DataSet();
clubconn=new SqlConnection(strclubconn);
clubconn.Open();
clubadapt=new SqlDataAdapter(userselect,clubconn);
clubadapt.Fill(dsclub,"UserTbl");
clubadapt.SelectCommand=new SqlCommand(strConCat,clubconn);
clubadapt.Fill(dsclub,"ConCat");
clubconn.Close();

clubdg.DataSource=dsclub;
clubdg.DataMember=dsclub.Tables["UserTbl"].ToString();
clubdg.DataBind();

concat.DataSource=dsclub;
concat.DataMember=dsclub.Tables["ConCat"].ToString();
concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();
concat.DataValueField=dsclub.Tables["ConCat"].Columns["ContactID"].ToString();
concat.DataBind();
}
This is the Front End DropDownList control: the error is refering to:

<asp:DropDownList ID="concat" Runat="server"></asp:DropDownList>

I don't know where the null referance is if any one can tell me what the
problem is I'd greatly appreciate it.

Sam I am-

Nov 19 '05 #2
Despite what you've shown us, contact must be null..even though you seem to
have it in the aspx page and seem to be declaring it protected in the
codebehind....maybe you are overwriting the value or something?

on a side note, instead of using:

concat.DataMember=dsclub.Tables["ConCat"].ToString();
concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();
concat.DataValueField=dsclub.Tables["ConCat"].Columns["ContactID"].ToString(
);

why not just use:

concat.DataMember= "ConCat";
concat.DataTextField="Catagory";
concat.DataValueField="ContactID";

karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"I am Sam" <Ia****@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
I keep getting the following exception 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 215: clubdg.DataBind();
Line 216:
Line 217: concat.DataSource=dsclub;
Line 218: concat.DataMember=dsclub.Tables["ConCat"].ToString();
Line
219: concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString();

Source File: c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs Line: 217
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Sonar3.Secured.UserGrid.BindData() in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :217
Sonar3.Secured.UserGrid.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :67
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

This error is refering to the following Code Behind:

protected System.Web.UI.WebControls.DropDownList concat;
protected System.Web.UI.WebControls.DataGrid clubdg;
string strclubconn=ConfigurationSettings.AppSettings["ConnectionString"];
protected System.Web.UI.WebControls.HyperLink HyperLink1;
string userselect="SELECT User_tbl.*, ConCat.* FROM User_tbl, ConCat WHERE
User_tbl.concat=Concat.ContactID ORDER BY UserID Desc";
string strConCat="SELECT ConCat.* FROM ConCat";

public void BindData()
{
dsclub=new DataSet();
clubconn=new SqlConnection(strclubconn);
clubconn.Open();
clubadapt=new SqlDataAdapter(userselect,clubconn);
clubadapt.Fill(dsclub,"UserTbl");
clubadapt.SelectCommand=new SqlCommand(strConCat,clubconn);
clubadapt.Fill(dsclub,"ConCat");
clubconn.Close();

clubdg.DataSource=dsclub;
clubdg.DataMember=dsclub.Tables["UserTbl"].ToString();
clubdg.DataBind();

concat.DataSource=dsclub;
concat.DataMember=dsclub.Tables["ConCat"].ToString();
concat.DataTextField=dsclub.Tables["ConCat"].Columns["Catagory"].ToString(); concat.DataValueField=dsclub.Tables["ConCat"].Columns["ContactID"].ToString(
); concat.DataBind();
}
This is the Front End DropDownList control: the error is refering to:

<asp:DropDownList ID="concat" Runat="server"></asp:DropDownList>

I don't know where the null referance is if any one can tell me what the
problem is I'd greatly appreciate it.

Sam I am-

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Herring | last post by:
Hi there: Well, let me start off by saying that I am a Visual Studio drag and drop weenie, not a real programmer. So I tend to get confused when things do not look like the instructions said they...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
1
by: Pums | last post by:
Hi All, I am trying to retrive an image from the database. when i click the button for the first time in which i have written the code of retrival it doesn't go into the code of filling the...
0
by: Joshua Russell | last post by:
Hi, Has anyone get some code that will enable to return a thread referance by searching for athread by name? Thanx Josh
5
by: I am Sam | last post by:
The codebehind is as follows: I have instenced the DataSet dsclub2a protected System.Data.DataSet dsclub2a; and I have instanced the DropdownList as follows: protected...
18
by: Denis Petronenko | last post by:
Hello, in the following code i have segmentaion fault instead of exception. Why? What i must to do to catch exceptions in such situation? Used compiler: gcc version 3.3.6 (Debian 1:3.3.6-13) ...
4
by: Hakan ÖRNEK | last post by:
Hi, I have two dll's like First.dll and Second.dll compiled by vb.net, a object in first.dll and, b object in Second.dll. I need hold cross referances; a.breferance=b and b.areferance=a I...
11
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
3
by: vimalankvk80 | last post by:
what will happen, if we forget to return ostream referance ? class A { Private: int _a; int _b;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.