473,748 Members | 5,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Table s(0).Rows(0)("m y_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...

RadioButtonList 1.Items.FindByV alue(CStr(myDat aSet.Tables(0). Rows(0)("my_bit _
column"))).Sele cted = True

But I get this beautiful error.."System. NullReferenceEx ception: 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 1777
Michael wrote:

RadioButtonList 1.Items.FindByV alue(CStr(myDat aSet.Tables(0). Rows(0)("my_bit _
column"))).Sele cted = True

But I get this beautiful error.."System. NullReferenceEx ception: 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
3033
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 example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
6
1809
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 want the first pick list to affect the other rows. At this time, when I change the first pick list, it is causing the second and third pick lists to change on all the rows. I just want it to change the second and third pick list on the currently...
0
1769
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 to be binded to the radiobutton list. I am not able to bind the datareader to the radiobuttonlist control as it is within the Itemtemplate. I am new to .Net. Could someone please let me know what I should be
1
5384
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. For DropDownList and RadioButtonList, there is only one item is selected and store in DB table.
2
4912
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 TextBoxes) works fine the first time round. I can see, edit and update the details from my form, then close the form. I then like to select and refill the datatable with a different record (new
4
12095
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%; text-align:center;"> <asp:RadioButton id="rbn01Approved" runat="server"
0
1355
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 ID="rblOdgovori" runat="server" DataSourceID='<%
14
14655
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 so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
2
1756
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 DataText field. However my database has a third column which includes a comment (nvarchar(50)) field, ItemComment. I would like this to appear next to the given text in the radiobuttonlist as a separate column. I would like the column to be either an...
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
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 we have to send another system
3
2206
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.