Hi,
I'm trying to do a survey and would like to populate labels with questions from database and dynamically generate text boxes and labels.
This is the structure of the database: (status 1 is active, 0 not)
QuestionsTable
QuestionID Question Status
1. 1 How are you? 1
2. 2 Test? 0
AnswersTable
AnswerID addressbookUserID QuestionID Response
1 2 6585 1 Good
2. 3 6585 2 Yes
I have 2 stored procedures that I use.
The first one is to load the questions:
USE [Portal] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[spSurveyQuestions] AS BEGIN SET NOCOUNT ON; select * from SurveyQuestions where Status = 1 END
The second one is to save the answers:
USE [Portal] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[spSaveResponses] ( @addressbookuserid as bigint, @QuestionId bigint, @Answer varchar(2000) ) AS BEGIN SET NOCOUNT ON; insert into dbo.surveyanswers (addressbookuserid, questionid, response) values (@addressbookuserid, @QuestionId, @Answer) END
What I want to do is load the first question into a label and then have a textbox under the label for it. And do that based on the number of the questions.
The other thing is the stored procedure is saving one question at a time. I need to save all the questions at once.
Any suggestions?