473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I am having huge problems with a null referance

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 System.Web.UI.WebControls.DropDownList ConCat1;

public void ContactCat()
{
dsclub2a=new DataSet();
clubconn=new SqlConnection(strclubconn);
clubadapt2=new SqlDataAdapter(strConCat,clubconn);
clubadapt2.Fill(dsclub2a,"ConCatagory");

ConCat1.DataSource=dsclub2a;
ConCat1.DataMember="ConCatagory";
ConCat1.DataTextField="Catagory";
ConCat1.DataValueField="ContactID";
ConCat1.DataBind();
}
In the Interface HTML file I have typed the following:

<asp:DropDownList id="ConCat1" runat="server"></asp:DropDownList>

I keep getting 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 219: clubadapt2.Fill(dsclub2a,"ConCatagory");
Line 220:
Line 221: ConCat1.DataSource=dsclub2a;
Line 222: ConCat1.DataMember="ConCatagory";
Line 223: ConCat1.DataTextField="Catagory";
Source File: c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs Line: 221

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Sonar3.Secured.UserGrid.ContactCat() in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :221
Sonar3.Secured.UserGrid.Edit_Click(Object sender,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\sonar3\secured\usergrid.aspx.cs :72
System.Web.UI.WebControls.DataGrid.OnEditCommand(D ataGridCommandEventArgs
e)
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source, EventArgs
e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source,
EventArgs e)
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Both ConCat1 and dsclub2a have been referanced properly. I do not know what
object the error message is refering to. I have used other names for these
objects as well and it still returns the same error. Is there something I am
missing?

I'm in real big trouble here I need to fix this. If someone can help me
figure it out I'll be truly greatful.

Sam-
Nov 19 '05 #1
5 1281
Sam ur code looks ok..
Hope i looked through it well!!!

What namespaces did u import?
Did you import
using System.Data;
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #2
But Sam after looking through it again in ur dropdownlist
<asp:DropDownList id="ConCat1" runat="server"></asp:DropDownList>
U are not retrieving any values for example like below

<asp:DropDownList id="ConCat1"
runat="server"
DataTextField="Catagory"
DataValueField="ContactID"
AutoPostBack="true" />
Let me know if that helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3
No that doesn't correct the problem. I am thinking I should call the
datasource in the actual DropDownList itself using <asp:DropDownList
ID="ConCat1a" DataSource="dsclub" DataMember="ConCat" Runat="server"
DataTextField="ContactID" DataValueField="Catagory" />

What do you think? Will that work?

"Patrick Olurotimi Ige" wrote:
But Sam after looking through it again in ur dropdownlist
<asp:DropDownList id="ConCat1" runat="server"></asp:DropDownList>
U are not retrieving any values for example like below

<asp:DropDownList id="ConCat1"
runat="server"
DataTextField="Catagory"
DataValueField="ContactID"
AutoPostBack="true" />
Let me know if that helps
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4
So Sam did that did the job?
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #5
It did the trick perfectly.

I just referanced the DataTable in the DropDownList control as such:

<asp:DropDownList ID="whatever_The_ID_IS" Datasource="<%# DataSet_Name%>"
DataMember="Table_Name" DataTextField="Column" DataValueField="PK_Column"
Runat="server"/>

that worked great. You have to keep in mind the Binding tags encapsolating
the DataSet Name. Very Important otherwise it won't bind to the DropDownList
control.

Sam I am-

"Patrick Olurotimi Ige" wrote:
So Sam did that did the job?
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #6

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

Similar topics

1
354
by: malcolm | last post by:
Hello, We have a small team building a project that involves some 30 or so c# assembly dlls. It is a client server application with 1 exe as the starting point. The dlls and exe are sharing an...
6
2859
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or...
1
2673
by: Reynardine | last post by:
I am calling a C/C++ DLL from C# and I am marshalling the parameters to the API call by doing a type conversion for each parameter. For example, here is my C++ API method : short int XENO_API...
2
1538
by: I am Sam | last post by:
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....
14
3453
by: Gotisch | last post by:
Hi, we are currently writing an mostly singlethreaded (game)server application in c#. But we are encountering problems with the Garbage Collector: After a certain time but also apparently...
4
1692
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...
3
1698
by: vimalankvk80 | last post by:
what will happen, if we forget to return ostream referance ? class A { Private: int _a; int _b;
38
2199
by: sam_cit | last post by:
Hi, I have the following Struct, Struct Sample { int i; char *p; };
1
4793
by: Claire | last post by:
Hi, I'm trying to run mysqldump.exe from my c# application, running on windows vista with visual studio 2005. The following code does not produce the output file. The same line used in a command...
5
1669
by: cpdar | last post by:
typedef struct FileHdr { unsigned long reg; unsigned short width; float sfactor; struct FileHdr huge *next; }FileHdr; FileHdr huge *Hdrhead=NULL,huge *Hdrcur=NULL; // //
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.