SRINI794 SRINI794 - 1 year ago 99 Question

Aligning radiobuttonlist in ASP.NET?

I have a aspx.vb code fragment which looks like this! (I am reading contents from xml config file to create radiobuttonlist)

Dim tr As TableRow = New TableRow

Dim tcValue As TableCell = New TableCell

Dim RadioButtonList = New RadioButtonList

//After this I load all the items in radiobuttonlist



Imagine this radiobuttonlist has 6 items.I want to create 2 columns which shoud consist of 3 radiobutton elements in each column and in a single row. How Can I go about implementing it?

Answer Source

If you're so keen to make a custom list, why not make a table and have something like this, having a list/array of RadioButtons instead of one RadioButtonList object:

(Sorry, I don't use VB except to scrape something together in Access, so you'll have to make do with my C#, which you should be able to interpret fairly easily)

RadioButton[] items = getAllItems();

int i = 0;
Table table = new Table();
TableRow currentRow;

foreach(RadioButton item in items)
   if(i != 0)
   if(i++ % 2 == 0)
      currentRow = new TableRow();
   currentRow.Cells.Add(new TableCell()

if(currentRow.Cells.Count != 0)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download