I'm currently working on a small quiz type app that populates questions and answers from an SQL .mdf database. I've been looking for a control in Visual Studio 2012 that could hold the four answers (preferably checkboxlist
).
The only problem is I have the questions saved in different columns, answer1
, answer2
etc.
The main question is, is there a way to populate the checkboxlist
control with multiple data fields rather than just one?
I tried using four separate checkboxlists
, but this made validation extremely difficult (Only one option should be selected). Does anyone have any advice or suggest how I could insert the four columns into a control that I could validate?
I read online about combining the answers using sql ie. SELECT Answer1 + ' ' + Answer2
, this works but again I don't know how to integrate this into a combo box list.
there are two easy ways:
on the database side you could use:
SELECT convert(Char,[Answer1]) FROM [TABLE1] union ALL SELECT convert(char,[Answer2]) FROM [TABLE1]
From the application side you could use Merge:
dim dt as new datatable
dt = SQLdataTable("SELECT [Answer1] FROM [TABLE1]")
dt.Merge(SQLdataTable("SELECT [Answer2] FROM [TABLE1]").Copy)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.