473,657 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB-WEB: Adding column to radiobuttonlist

5 New Member
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 asp:label,text or literal so based on other conditions I could display or hide it.

Although I need this for something different, I could see a very practical need for this by having a textbox in line with a radiobutton item text of "Other" where the user would need to populate what the other is and was suprised that I could find nothing in my many searches.

Thanks to the one who knows,
TJ
Jun 13 '07 #1
2 1752
nateraaaa
663 Recognized Expert Contributor
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 asp:label,text or literal so based on other conditions I could display or hide it.

Although I need this for something different, I could see a very practical need for this by having a textbox in line with a radiobutton item text of "Other" where the user would need to populate what the other is and was suprised that I could find nothing in my many searches.

Thanks to the one who knows,
TJ
I am not quite sure why you have so many radiobuttons displaying on a page. I tried recreating your situation and it is a hassle to scroll that far to find what you want but that is your choice. As far as adding a column I have found a way to add text to the right of your radiobuttonlist text. You will need to do the following.

Expand|Select|Wrap|Line Numbers
  1. RadioButtonList2.DataSource = datasetname;
  2. RadioButtonList2.DataTextField = "ItemText ";
  3. RadioButtonList2.DataValueField = "ItemVal ";
  4. RadioButtonList2.DataBind();
  5.  
  6. int i = 0;
  7. foreach(ListItem item in RadioButtonList2.Items)
  8. {
  9. item.Text = item.ToString() + " " + datasetname.Tables[0].Rows[i]["ItemComment"].ToString();
  10. i ++;
  11. }

You can add as many spaces between the text as you would like. In my example I only added one space.

Good Luck

Nathan
Jun 13 '07 #2
manonbar
5 New Member
Nathan,

Even though I had a situation that seemed impractical with many radio list items, I still believe this is a very practical need to get textboxes or other text in-line with radio button items.

Your solution puts me on the right track as I will need some sort of loop, but your solution merely joins my text. I can do the same and avoid by the loop concatenating "ItemText" with "ItemCommen t" in the SQL command or in the second line..

RadioButtonList 2.DataTextField = "ItemText " & " " & "ItemCommen t"

However, I am trying to get a separate object like a textbox, literal control or label to appear in-line next to each RadioButton List item. My attempt falls apart at the ???<asp:label spot below as I don't know what to place there or reference since I cannot just add a label in the form portion within the radiobuttonlist especially when the radiobutton is built using the DataBind(). I did need this in VB and modified your code as

RadioButtonList 2.DataSource = datasetname
RadioButtonList 2.DataTextField = "ItemText "
RadioButtonList 2.DataValueFiel d = "ItemVal "
RadioButtonList 2.DataBind()

dim i as integer = 0
For each ListItem item in RadioButtonList 2.Items
item.Text = item.ToString() + &nbsp; + ???<asp:label text=datasetnam e.Tables(0).Row s(i).("ItemComm ent").ToString( ) />???
Next
Jun 13 '07 #3

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

Similar topics

16
486
by: Terry | last post by:
Hi, I need some feedback. We are converting to .Net and we are trying to decide on whether to use VB.net or C#.net. As far as our current systems, they will probably be rewritten in ASP.Net. I have looked into both and I don't see anything that would scream out to use one or the other. So at this point, it is still a toss up. However, I want to look at the two languages from a different perspective. That is from a career point of view....
13
5146
by: Arsalan | last post by:
Is there any advantage in C# over VB.NET ? Or the difference is only syntax ? Can anything done in C# which cannot be done in VB.NET?
28
2437
by: Andy | last post by:
Any good resources regarding benefitis by using C3 over VB? /Andy
12
1651
by: Leo Muller | last post by:
I always thought that moving from VB.NET to C# would be very easy. Even though so far it hasn't been hard, there are some annoying things, that may have to do with my visual studio settings. - When I type "system." the intellisense doesn't comlete this, only if I write it with a capital S, rather annoying... - is the type "string" or "String", both get excepted, but only "string" gets marked in blue, while all examples use "String" -...
16
2588
by: Ben Hannon | last post by:
Hi, I'm writting a COM Class in VB.NET to be used in a VB6 project (Tired of the VB6 hassles with cloning and serializing an object). All my classes I need cloneable/serializable are now in a VB.NET class that exposes those objects to COM perfectly. However I ran into a problem because some of these objects requires a Collection. When I compile this project with the VB.NET Collection exposed for a property, I get a compile time error...
182
7492
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
25
1815
by: Sharrukin Amiri | last post by:
Hello, I am using VB 6.0 for many years. Everytime I needed to build software applications, I just opened VB 6.0 and started coding. I am now looking VB.NET Express Edition and I find I can no longer do this very easily. I find that there is too much copy and paste of code in order to get an app running. I also find it slow. Is it me or I am missing something? Here is a sample of my coding which you could find at: ...
2
1684
by: D H | last post by:
Hi, Hi, I was looking for your opinion on VB.NET - its long-term prospects, etc. Sorry this is vague, but it's not meant to be a troll. It's a pro-VB.NET post actually. I haven't used VB or VB.NET really, but I have used Realbasic (a vb clone), Java, C#, C, and Python. I work in education, and I'd like something that is easy enough for teachers and students to use to develop real, usable applications, not just to learn programming for...
19
3079
by: lonelyplanet | last post by:
Hi, I'm studying for 70-306 using the book "MCAD/MCSD Visual Basic .NET Windows Applications" published by McGraw Hill (ISBN: 0-07-212583-7). I found the book has no programming exercise provided about how VB.NET work with XML documents (certification objective 15.02). I'm now searching for some example source codes to assist my study. Could anyone also suggest me some useful online study resources ?
0
8326
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
8845
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...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
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
4173
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
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.