Replace radiobuttonlist  with checkbox list at runtime

mmalik15 used Ask the Experts™
My quiz engine is implemented like this

My table is like this
Id    Question       Choices       CorrectAnswer                  Type
1      xxxx          a,b,c,d          a     choices are splitted by comma.      Rbutton,Checkbox
And  ListView is designed like this:
<asp:ListView... ItemPlaceHolder = "trPlaceHolder" DataKeys="Id">
  <table width=100%>
    <asp:RadioButtonList id = "rbtChoices" runat="server" DataSource='<%#AutoConvert(Eval("trPlaceHolder"))%>'>
Page_Load event is as follows
private void Page_Load(....)
  ListView1.DataSource = xxx;
AutoConvert function should be this:
protected string[]AutoConvert(object values)
 return values.ToString().Split(',');
There is a button out of ListView, in the click event, we loop each item of the listview and use FindControl to get the selected radio's Text:
private void Button_Click(....)
 foreach(ListViewDataItem item in ListView1.Items)
  DataRowView dv = (DataRowView)item;
  string correctValue = dv.Row["Your ColumnName here..."];
  RadioButtonList rbLst = (RadioButtonList)item.FindControl("rbtChoices");
  if(rbList.SelectedItem.Text == correctValue)
   //do what we like here...

how can I replace  radiobutton list with checkbox list if question type is checkbox and viceversa

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you can toggle visibility depending on the type.

if type == checkbox...
checkboxlist.visible = true
radiolist.visible = false
else if type == radio
checkboxlist.visible = false
radiolist.visible = true

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial