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
tcValue.Controls.Add(tdRadioButtonList)
tr.Cells.Add(tcValue)
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?
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)
table.Rows.Add(currentRow);
if(i++ % 2 == 0)
currentRow = new TableRow();
currentRow.Cells.Add(new TableCell()
{
Controls.Add(item)
});
}
if(currentRow.Cells.Count != 0)
table.Rows.Add(currentRow);
Page.Controls.Add(table);