473,382 Members | 1,238 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,382 software developers and data experts.

Data Binding a Bit Column to RadioButtonList

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
Nov 18 '05 #1
1 1765
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
Nov 18 '05 #2

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

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
6
by: Mike Kirkpatrick | last post by:
I have this data grid which consists of 3 pick lists. The first pick list is to affect the data binding of the other two. I have figured out how to do the data binding by column. However, I do not...
0
by: ani | last post by:
Hi, I have a datalist control and within the Itemplate I have a radiobuttonlist control . I am binding data to the datalist control in Page_load . Also I have sqldatareader object that needs...
1
by: Tom | last post by:
Hi, I have a webform which has DropDownList, RadioButtonList and CheckBoxList. All values are in webform, but not select from DB table as they do not need to be used as search requirements. ...
2
by: Matthias | last post by:
Hi Team this may be a newbie question. I have searched the discussions before posting: I'd like to re-use a form instance to edit record details. My data binding (a DataTable bound to...
4
by: sck10 | last post by:
Hello, I am trying to use a radiobutton inside of a FormView for editing data. My question is how do you bind the radio buttons to the data field? Thanks, sck10 <td style="width:30%;...
0
by: papaja | last post by:
I have gollowing code: <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%#Eval("Pitanje") %>'></asp:Label> <asp:RadioButtonList...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
2
by: manonbar | last post by:
I have a radiobuttonlist bound to a dataset on the Page Load event, it has about 150 items. I used two columns from my SQL Server database, ItemVal for the DataValue field and ItemText for the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.