Thursday, March 22, 2012

System.NullReferenceException: Object variable or With block varia

Hello -

I don't know if it's possible or not, but I am trying to bind data from a
Sql Server DB to the header in a datalist. I received the above error
message.

First, is it possible to bind data from a DB to the header and if so, what
could be causing the error message?

Alternatively, can you only put text in the header of a datalist?
--
SandySandy,
You didn't provide any code many it very difficult to imagine what the error
is...

Yyou can't bind data to a header in the typical databinding sense.
Information is bound row-by-row to the individual items...There's no row
assigned to the header...you can set values of the header progamatically
however...

myGrid.Columns(0).HeaderText =
myDataSet.Tables(0).Rows(0)("Blah").ToString()

or something similar...

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!)
"Sandy" <Sandy@.discussions.microsoft.com> wrote in message
news:BBD0DEED-455D-473C-8D00-8D969825BCF6@.microsoft.com...
> Hello -
> I don't know if it's possible or not, but I am trying to bind data from a
> Sql Server DB to the header in a datalist. I received the above error
> message.
> First, is it possible to bind data from a DB to the header and if so, what
> could be causing the error message?
> Alternatively, can you only put text in the header of a datalist?
> --
> Sandy
Thanks, Karl!

"Karl Seguin" wrote:

> Sandy,
> You didn't provide any code many it very difficult to imagine what the error
> is...
> Yyou can't bind data to a header in the typical databinding sense.
> Information is bound row-by-row to the individual items...There's no row
> assigned to the header...you can set values of the header progamatically
> however...
> myGrid.Columns(0).HeaderText =
> myDataSet.Tables(0).Rows(0)("Blah").ToString()
> or something similar...
> 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!)
> "Sandy" <Sandy@.discussions.microsoft.com> wrote in message
> news:BBD0DEED-455D-473C-8D00-8D969825BCF6@.microsoft.com...
> > Hello -
> > I don't know if it's possible or not, but I am trying to bind data from a
> > Sql Server DB to the header in a datalist. I received the above error
> > message.
> > First, is it possible to bind data from a DB to the header and if so, what
> > could be causing the error message?
> > Alternatively, can you only put text in the header of a datalist?
> > --
> > Sandy
>

0 comments:

Post a Comment