Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a small project in c#. It is like a questionaire. Administrator has the option to add as many questions she want and the answer type may also differ for each question.The questions are coming from database . I am storing all the questions in a datagridview. How can I create the questions and its answer type dynamically based on the number of questions in a datagridview
Posted

1 solution

By changing the data source to contain the questions and answers you want it to, and then writing code that can bind to that data source. There's no controls to add dynamically here, you're showing data in a databound control, so you just need to change the data. I'd expect this would be a data bound control for each question, with a databound control inside it for an arbitrary number of answers. Hard to say more, as you give no clues what you're using ( WPF, winforms, silverlight, ASP.NET, MVC, etc )
 
Share this answer
 
Comments
lilian87 13-Nov-12 10:34am    
It is a desktop application in c#
Christian Graus 13-Nov-12 10:37am    
Still not enough. Winforms ? WPF ?
lilian87 13-Nov-12 10:38am    
winforms
Christian Graus 13-Nov-12 10:54am    
So to add a control, you just create it, set it's position ( top, width etc ) and add it to the form's 'controls' collection, as in this.Controls.Add(x);. But again, you should not need to do that

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