Click here to Skip to main content
15,063,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using c# MVC 4 and I would like to create Multiple user controls and fill data dynamically.

Eg: I have a history filling form and in it i have to display multiple question having options control which can be radio button or check box also have a text-area with every question.So I do not know the field names and its control types prior to visiting this page, it gets the data and control types from a sql table with question:

field 1: Text-Label

field 2: DropdownList (values: 1,2,3,4,5) or radio button or check-box or text-box

field 3: textarea

How do I achieve this?

Hi Honey,

You can use templates to achieve this. You can create display or editor templates under shared folder. Naming of the template can be done based on the control name coming from SQL. So for e.g. u have three control names coming from SQL - TextArea, RadioButton and CheckBox. So when you call Displayfor or Editorfor helper methods it wud try to see files (TextArea.cshtml etc.) under folders Views/Shared/DisplayTemplates or Views/Shared/EditorTemplates respectively respectively. Please let me know if you face any issue while implementing it.
Hi Honey,

I know it's already been months since you posted your question and you might have found the solution already. I just thought I post some links to give you an idea and to others as well.

here are the link:[^][^]

let me know if these helps you or if there's anything I can help you with.

Member 11848749 27-Jul-15 6:11am
BY CLICKIN THESE lINKS I'M GETTING LYK"This webpage is not available"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900