By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,491 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,491 IT Pros & Developers. It's quick & easy.

DataGrid's DataBind() error

P: n/a
Dee
Hi,
I'm working on a sample WebForm proj that accesses an Access database.
There is a desgn-time
DataSet ds1
and a
DataGrid dg.

Page_Load contains 2 lines:
da.Fill(ds1)
dg.DataBind().

I have set the DataSource of dg set to ds1 and DataMemeber to a table
therein.

I get
System.NullReferenceException: "Object reference not set to an instance
of an object"
error when aspnet tries to execute dg.DataBind().

Any help appreciated.
Dee
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Dee
I got the BindData() to work but then the columns I set to display is
completely ignored but
only sometimes.
Is the DataGrid difficult to tame?
"Dee" <dee@home> wrote in message
news:#l**************@tk2msftngp13.phx.gbl...
Hi,
I'm working on a sample WebForm proj that accesses an Access database.
There is a desgn-time
DataSet ds1
and a
DataGrid dg.

Page_Load contains 2 lines:
da.Fill(ds1)
dg.DataBind().

I have set the DataSource of dg set to ds1 and DataMemeber to a table
therein.

I get
System.NullReferenceException: "Object reference not set to an instance of an object"
error when aspnet tries to execute dg.DataBind().

Any help appreciated.
Dee

Nov 19 '05 #2

P: n/a
On Sun, 17 Apr 2005 13:09:14 -0500, Dee <dee@home> wrote:
I got the BindData() to work but then the columns I set to display is
completely ignored but
only sometimes.
Is the DataGrid difficult to tame?
"Dee" <dee@home> wrote in message
news:#l**************@tk2msftngp13.phx.gbl...
Hi,
I'm working on a sample WebForm proj that accesses an Access database.
There is a desgn-time
DataSet ds1
and a
DataGrid dg.

Page_Load contains 2 lines:
da.Fill(ds1)
dg.DataBind().

I have set the DataSource of dg set to ds1 and DataMemeber to a table
therein.

I get
System.NullReferenceException: "Object reference not set to an

instance
of an object"
error when aspnet tries to execute dg.DataBind().

Any help appreciated.
Dee



Well, it is pry the largest beast in ASP.NET :) But actually it's not
that bad; we'd need to see some code here to see what's wrong. Mainly the
asp:datagrid code from your aspx and the code where you're binding the
dataset to it. Without that we won't be able to tell if, for example,
AutoGenerateColumns is set to false appropriately, etc.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #3

P: n/a
Dee
Thanks Craig,
I needed a good ol reboot. Bunch of strange things was happening including
when i made changes in the desgin view the code behind didnt get updated
and irinically when it did it was followed by a "Catastrophic Failure!"
message.
Anyway i dont want to jinx it but its behaving now.
Thanks again.
Dee

"Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
news:op***************@cowboy.hsd1.mn.comcast.net. ..
On Sun, 17 Apr 2005 13:09:14 -0500, Dee <dee@home> wrote:
I got the BindData() to work but then the columns I set to display is
completely ignored but
only sometimes.
Is the DataGrid difficult to tame?
"Dee" <dee@home> wrote in message
news:#l**************@tk2msftngp13.phx.gbl...
Hi,
I'm working on a sample WebForm proj that accesses an Access database.
There is a desgn-time
DataSet ds1
and a
DataGrid dg.

Page_Load contains 2 lines:
da.Fill(ds1)
dg.DataBind().

I have set the DataSource of dg set to ds1 and DataMemeber to a table
therein.

I get
System.NullReferenceException: "Object reference not set to an

instance
of an object"
error when aspnet tries to execute dg.DataBind().

Any help appreciated.
Dee



Well, it is pry the largest beast in ASP.NET :) But actually it's not
that bad; we'd need to see some code here to see what's wrong. Mainly the
asp:datagrid code from your aspx and the code where you're binding the
dataset to it. Without that we won't be able to tell if, for example,
AutoGenerateColumns is set to false appropriately, etc.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 19 '05 #4

P: n/a
You can try:

da.Fill(ds1)
dg.DataSource = ds1
' or
dg.DataSource = ds.Tables(0)
' or
dg.DataSource = ds.Tables(0).DefaultView
dg.DataBind()

HTH

Elton Wang
el********@hotmail.com
-----Original Message-----
Hi,
I'm working on a sample WebForm proj that accesses an Access database.There is a desgn-time
DataSet ds1
and a
DataGrid dg.

Page_Load contains 2 lines:
da.Fill(ds1)
dg.DataBind().

I have set the DataSource of dg set to ds1 and DataMemeber to a tabletherein.

I get
System.NullReferenceException: "Object reference not set to an instanceof an object"
error when aspnet tries to execute dg.DataBind().

Any help appreciated.
Dee
.

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.