General Approach to DropDownLists
-
Hi, I've just done a basic "survey" web page which lists a number of questions for users to fill in and submit - each survey is then saved to a SQL database in the "Survey" table. At the moment, the questions are multiple choice, so the answers are yes/no, or strings of text. One of the question's answers is some 30 characters long and virtually all the answers can be chosen from DropDownList controls. It all works fine as it it is but as you can imagine, while I can store the strings of text in each record it seems that a more efficient way would be to store the index of the choice from the DropDownList so I'd be able to use INTs instead of NTEXT. My problem is this: should I implement a table for each question on the database consisting of a string and int value and bind the web controls on page load; or should I have some sort of enum type for each question with a DropDownList. If the latter, how can I associate a string of text with an int? I can't create a set of enums containing text can I? Thanks for any help :)
-
Hi, I've just done a basic "survey" web page which lists a number of questions for users to fill in and submit - each survey is then saved to a SQL database in the "Survey" table. At the moment, the questions are multiple choice, so the answers are yes/no, or strings of text. One of the question's answers is some 30 characters long and virtually all the answers can be chosen from DropDownList controls. It all works fine as it it is but as you can imagine, while I can store the strings of text in each record it seems that a more efficient way would be to store the index of the choice from the DropDownList so I'd be able to use INTs instead of NTEXT. My problem is this: should I implement a table for each question on the database consisting of a string and int value and bind the web controls on page load; or should I have some sort of enum type for each question with a DropDownList. If the latter, how can I associate a string of text with an int? I can't create a set of enums containing text can I? Thanks for any help :)
Consider a general table called, "Survey", in this table you could store an XML file which would have both your questions and your values of drop down boxes. You could then create another table called "SurveyResults" which would store the results of your survey in an XML file. By using a design like this, you could have vastly different surverys and not have to change your storage structure. Something to think about.
-
Hi, I've just done a basic "survey" web page which lists a number of questions for users to fill in and submit - each survey is then saved to a SQL database in the "Survey" table. At the moment, the questions are multiple choice, so the answers are yes/no, or strings of text. One of the question's answers is some 30 characters long and virtually all the answers can be chosen from DropDownList controls. It all works fine as it it is but as you can imagine, while I can store the strings of text in each record it seems that a more efficient way would be to store the index of the choice from the DropDownList so I'd be able to use INTs instead of NTEXT. My problem is this: should I implement a table for each question on the database consisting of a string and int value and bind the web controls on page load; or should I have some sort of enum type for each question with a DropDownList. If the latter, how can I associate a string of text with an int? I can't create a set of enums containing text can I? Thanks for any help :)
I think you need to work on the database design first before you tackle the front end. Like you said - create a table with list of questions. Create another table with list of possible answers per question. This will give you Id(s) to work with for question and answer. About the dropdowns,you have to display the data in the dropdowns, so that needs to be transported to the browser. While writing back to the server, you can use the selected id(s) of the answers. This way you can use bound controls as well. Hope this helps. Shreekar