PC Review


Reply
Thread Tools Rate Thread

Data Binding a Bit Column to RadioButtonList

 
 
Michael
Guest
Posts: n/a
 
      2nd Jan 2004
Hi,

This should be fairly simple, but it is driving me nuts. First off I have a
table in SQL Server, with a column of type "bit". This is meant to store a
answer to a Yes/No question.

I'm trying to display this stored value in SQL Server in a RadioButtonList
in ASP.NET. I have the value stored in ado.net DataSet, which I can
reference just like this
myDataSet.Tables(0).Rows(0)("my_bit_column")

My problem is, I don't know how to bind this result, to the RadioButtonList.
I would believe I need to use the RadioButtonList's methods FindByText or
FindByValue methods, and I've tried something like this...

RadioButtonList1.Items.FindByValue(CStr(myDataSet.Tables(0).Rows(0)("my_bit_
column"))).Selected = True

But I get this beautiful error.."System.NullReferenceException: Object
reference not set to an instance of an object."

Can anyone help me out, it seems I'm making this more complicated that it
has to be!

Thanks!
--Michael


 
Reply With Quote
 
 
 
 
Craig Deelsnyder
Guest
Posts: n/a
 
      2nd Jan 2004
Michael wrote:
>
> RadioButtonList1.Items.FindByValue(CStr(myDataSet.Tables(0).Rows(0)("my_bit_
> column"))).Selected = True
>
> But I get this beautiful error.."System.NullReferenceException: Object
> reference not set to an instance of an object."
>
> Can anyone help me out, it seems I'm making this more complicated that it
> has to be!
>
> Thanks!
> --Michael
>
>


Apparently it can't find that value in the FindByValue. Are you sure
you do a DataBind before trying to do this line? Otherwise your items
in the list aren't created yet....

--
Craig Deelsnyder
Microsoft MVP - ASP.NET
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding RadioButtonList to a SQL bit column through SQLDataSource mbosco51@hotmail.com Microsoft ADO .NET 1 29th Apr 2008 07:10 PM
FormView - RadioButtonList binding =?Utf-8?B?VGlt?= Microsoft ASP .NET 2 28th Apr 2006 05:17 PM
Re: HyperLink Column - Data Binding? naijacoder naijacoder Microsoft ASP .NET 1 9th Sep 2005 01:41 AM
binding data to a radiobuttonlist within an ItemTemplate ani Microsoft ASP .NET 0 30th Oct 2003 09:11 PM
Binding RadioButtonList ... Ivan Demkovitch Microsoft ASP .NET 2 19th Aug 2003 03:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 AM.