Link to home
Start Free TrialLog in
Avatar of bolenka
bolenka

asked on

How do I set the height and display attributes for a dynamic radiobuttonList on a form in asp.net vb?

I am adding list items to a radiobuttonlist from a database dynamically in ASP.Net VB. When I view the form, the radiobuttonlist is all sprawled out over the page. There is sooooo much space between the listitems I have dynamically added.

How do I format a dynamically added RadiobuttonList in asp.net 2.0 VB?
Thanks so much.
Avatar of AmarIs26
AmarIs26

The radiobutton list renders two elements. Label and Input. Make sure that your css files or css styles are not setting the styles of these two elements which might cause them to look too far apart etc.
Also by default the "RepeatDirection" property of the RadioButtonList is set to Verticle. If thats what you want ensure that, this value is set because otherwise your radio buttons will be all rendered on the same line.
Finally, ensure that the RepeatLayout property of the radiobuttonlist is set to Table.
It would help if you could post some screenshots and css styles that are currently applied to the page elements.
Avatar of bolenka

ASKER

ok, I didnt know that it rendered two elements. Is it possible to take the label text that the radiobutton is outputting and output the results on postback (without the actual button part)? Meaning if I have a radiobutton and the user selects an answer and clicks submit then can I just show the results from the label of the radiobuttonlist without the actual buttons. I don't want the user to be able to click the button again after postback.

I think I acually my CSS was causing the problem...so thank you. I did not know that it rendered 2 elements separately. Can you tell how it renders by Viewing Source?

yes you can, i would suggest you download whats called "Developers toolbar" its an addin to IE by microsoft which lets you click on any element and see its structure. You can also dynamically apply css styles and see what effect it would have on elements. So when something apears out of place you can try to fix it by applying styles.
http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en
 
 
Also to answer your first question,. what you can do is that when your radiobuttonlist is being built (either by adding Listitem in a loop or by databinding)
you can get a reference to the listitem , identify that it is currently ticked and then disable it so the user cannot select it again.
IF you are doing something like
RadioList.DataSource = dbresult;
RadioList.Databind();
then you need to handle the itemcreated or radiolist.itemdatabound event (i am typing this without vs so the event names might not be exact so just look for something similar). in one of these events you can get a reference to the ListItem that is being added to the list during databind and then you can do the check to enable/disable the item.
If you are adding items to your radiobuttonlist in a loop then it should be easy to add the necessary code in the loop.
Avatar of bolenka

ASKER

I am actually adding items to my radiobuttonlist in a loopin the PageLoad event. Is this the correct event to add them? Then I just disable them on postback?

One last question since you have been so helpful, what would be the best way to display info abou t the button that was clicked? Would I just disable it on postback and set the drawing color on postback?

(Red for incorrect, green for correct) and then I have to display a label to display statistics data...can I append information to the list item on postback to post information about the chosen answer? (i.e"88% of users have chosen this answer..12% of users have chosen this answer")...or would it be better to use a label

If I load the data on page load into a datarow loop:
For Each row As Data.DataRow In matchRows
Next

then howdo I append information about the answer on postback?

P.S. I wish I could give you 1000 points you have been so helpful:) I have downloaded the tool you suggested and will take a look at it shortly...thanks for that as well.
ASKER CERTIFIED SOLUTION
Avatar of AmarIs26
AmarIs26

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bolenka

ASKER

awesome, I have a related question, but I wanted to give you point first. thanks sooo much.