473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP List with Radio buttons

iam_clint
1,208 Recognized Expert Top Contributor
Alright I have a page that I have multiple radio buttons being drawn to the page reading from the database. Example

Permissions
Google - ( ) on (x ) off
Nvidia - ( ) on (x ) off
Newegg- ( x) on ( ) off


Google, Nvidia, and Newegg are in a table and it also includes a site id such as
site_id, site_name
1, newegg
2, google
3, nvidia


Another table with user permissions in it
user_id, site_access
1, 1
1, 2
1, 3
2, 2
3, 1
4, 2


I am currently attempting this with a repeater, It writes the radio buttons to the page beautifully.
Expand|Select|Wrap|Line Numbers
  1. <asp:Repeater runat="server" ID="sites">
  2.                                         <HeaderTemplate></HeaderTemplate>
  3.                                         <ItemTemplate>
  4.                                         <tr>
  5.                                         <td style="width: 190px; height: 21;" class="member_textlabel"><%#Container.DataItem("site_name")%></td>
  6.  
  7.                                         <td style="height: 21px;">
  8.                                         <table cellpadding="0" cellspacing="0" style="width: 170">
  9.                                             <tr>
  10.                                                 <td style="width: 24px">
  11.                                                 <asp:RadioButton  runat="server" GroupName="site_access" ID="site_on" /></td>
  12.                                                 <td class="member_textlabel" style="width: 41px"><%#Container.DataItem("site_id")%>
  13.                                                 On</td>
  14.                                                 <td style="width: 20px">
  15.                                                 <asp:RadioButton  runat="server" GroupName="site_access" ID="site_off" /></td>
  16.                                                 <td class="member_textlabel">
  17.                                                 Off</td>
  18.                                             </tr>
  19.                                         </table>
  20.                                         </td>
  21.                                         </tr>
  22.                                         </ItemTemplate>
  23.  

But i cannot figure out how to read these radio buttons server side.

so first thing it needs to put checkboxes in the proper places and next it needs to be able to be modified such as changing the radio button configuration and hitting a save button. So i need to do this in a way i can know what site_id's are on and off server side.
Dec 16 '08 #1
7 2734
Frinavale
9,735 Recognized Expert Moderator Expert
Are you doing this as an exercise to learn how to use repeaters?
There is an easier way to do this ...

Anyways, you need to use the FindControl method to retrieve the RadioButton from the repeater and then check it's value.

C#:
Expand|Select|Wrap|Line Numbers
  1. RadioButton rdo = (RadioButton)myRepeater.FindControl("rdoID");
VB.NET
Expand|Select|Wrap|Line Numbers
  1. Dim rdo As RadioButton = DirectCast(myRepeater.FindControl("rdoID"), RadioButton)
-Frinny
Dec 16 '08 #2
iam_clint
1,208 Recognized Expert Top Contributor
no by all means if there is a different better way to accomplish this let me know.. I am fairly new to asp.net and .net in general.

On a side note I'm not sure how to give each radio button a unique id then be able to grab it in the code because this is all database driven. Is there a way to grab an array of the radio buttons?
Dec 17 '08 #3
Frinavale
9,735 Recognized Expert Moderator Expert
When you talk about grabbing an array of RadioButtons, are you talking about client side or server side.

A RadioButtonList is basically an array of RadioButtons. It's better to use RadioButtonList s in your solution instead of individual radio buttons....main ly because it's hard to set unique IDs for individual radio buttons.

I think using CheckBoxes instead of RadioButtons is probably going to be easier for you in the long run...because then all you have to do is check whether or not the CheckBox has been selected, rather than checking which RadioButton is selected.

Are you not using a GridView because of the overhead costs?
Dec 17 '08 #4
iam_clint
1,208 Recognized Expert Top Contributor
i'm not using gridview because i've been using .net for about 3 weeks.
Yes this page wasn't my design but if I absolutely have to I can change it to checkboxes can you give me a small working example please, content is dynamic.
Dec 17 '08 #5
Frinavale
9,735 Recognized Expert Moderator Expert
@iam_clint
Give me a bit and let me see if I can't get something running :)

Are you displaying the site permissions for a single user or for all users at a time?

<edit> oh and what .NET framework are you using?</edit>
Dec 17 '08 #6
iam_clint
1,208 Recognized Expert Top Contributor
.net version is 3.5

its single user at a time.. the dynamic things are just the sites and their id's

Thanks for the help i've been messing around with it to no avail
Dec 17 '08 #7
Frinavale
9,735 Recognized Expert Moderator Expert
I'm sorry but I got pulled into a meeting for most of the day and wasn't able to look into this.

I've got an idea for a solution though :)
Using an ItemTemplate and GridView.

I'll give it a whorl tonight

-Frinny
Dec 17 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3156
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
4
3283
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
6
3295
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked The problem i am facing is that i do not know how many yes/no radio groups will be generated
10
2378
by: Jay | last post by:
Good afternoon, I have a radio list box called rblNavigateOptions and I need to be able to simply set one of those radio items to disabled before any item is selected by a user. ie. When the rblNavigateOptions control is created one or some of the items it contains are disabled.
2
11987
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put them each in a GroupBox. All the examples I saw from the books or from the web show me how to add static radio buttons at design, or dynamically at run time but with fixed radio buttons (like from an array). I need to create radio buttons based...
1
6892
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and grandtotal the costs ready for the selected items to be inserted back to the database. I did something like this before with Checkboxes, but Radio button have to be named the same to maintain their groupings.
0
1654
by: Robert J. Bonn | last post by:
I am setting up a contact list for a musician, who is about to release her first CD. She would like a contact list that can track all the people she meets, who will be in various categories -- fans, radio station personnel, owners of clubs, other musicians, etc. Ideally, I'd like to create a form that asks basic questions for everyone (name, phone number, etc.) No problem. But then, there will be different kinds of information,...
2
5897
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on the form by changing the visible state of the radio buttons and labels utilising back and next buttons. E.g. Next button makes current radio buttons and labels invisible and
4
5726
by: CURTISLESPERANCE | last post by:
Hi, I am trying to figure out if this is possible. I need to display 4 radio buttons next to a question then 3 radio buttons after. The 2 different group radio buttons and questions are coming from a database. I have the questions being displayed right now using a repeater control but I am having an issue making 4 and 3 radio buttins per question for multiple questions. However some questions have sub questions so the parent question...
0
9699
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
9562
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
10538
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
10285
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
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6838
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
5494
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...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.