Solved

How can I assign an ID number to a section of code so that it pulls the appropriate details into the radio list?

Posted on 2004-08-31
10
170 Views
Last Modified: 2010-04-23
The following code pulls a question and assigns it to a label 'lblQ1'

Then ObjCommand.ExecuteReader() pulls in question options from a datasource and assigns them to a radiolist.

lblQ1.Text=(ObjCommand.Parameters("@ReturnQuestion1").Value)

How can I assign an ID number to this section of code so that it pulls the appropriate details into the radio list?
You see, I have a few radiolists one after the other.

Basically, I am trying to pull the appropriate options for each question. At the moment its not matching up the questions with answers.

Sorry, its a difficult problem to explain ....hope this makes some sense.

      RadFSAQ1.DataSource=ObjCommand.ExecuteReader()
      RadFSAQ1.DataTextField="AnswerDescription"
      RadFSAQ1.DataBind()
      objConnection.Close()

Cheers

PG

0
Comment
Question by:pgilfeather
  • 4
  • 3
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11941968
What is the SQL for filling the radio button list?

Bob
0
 

Author Comment

by:pgilfeather
ID: 11941992
@QuestionID1 Int,
@QuestionID2 Int,
@QuestionID3 Int,
@QuestionID4 Int,
@QuestionID5 Int,
@QuestionID6 Int,
@QuestionID7 Int,
@QuestionID8 Int,
@QuestionID9 Int,
@QuestionID10 Int,
@QuestionID11 Int,
@QuestionID12 Int,
@QuestionID13 Int,
@QuestionID14 Int,
@QuestionID15 Int,
@QuestionID16 Int,
@QuestionID17 Int,
@QuestionID18 Int,
@QuestionID19 Int,
@QuestionID20 Int,
@ReturnQuestion1 varchar(8000)OUT,
@ReturnQuestion2 varchar(8000)OUT,
@ReturnQuestion3 varchar(8000)OUT,
@ReturnQuestion4 varchar(8000)OUT,
@ReturnQuestion5 varchar(8000)OUT,
@ReturnQuestion6 varchar(8000)OUT,
@ReturnQuestion7 varchar(8000)OUT,
@ReturnQuestion8 varchar(8000)OUT,
@ReturnQuestion9 varchar(8000)OUT,
@ReturnQuestion10 varchar(8000)OUT,
@ReturnQuestion11 varchar(8000)OUT,
@ReturnQuestion12 varchar(8000)OUT,
@ReturnQuestion13 varchar(8000)OUT,
@ReturnQuestion14 varchar(8000)OUT,
@ReturnQuestion15 varchar(8000)OUT,
@ReturnQuestion16 varchar(8000)OUT,
@ReturnQuestion17 varchar(8000)OUT,
@ReturnQuestion18 varchar(8000)OUT,
@ReturnQuestion19 varchar(8000)OUT,
@ReturnQuestion20 varchar(8000)OUT
AS
BEGIN
SET @ReturnQuestion1 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID1 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID1 = QuestionID
END

BEGIN
SET @ReturnQuestion2 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID2 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID2 = QuestionID
END

BEGIN
SET @ReturnQuestion3 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID3 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID3 = QuestionID
END

BEGIN
SET @ReturnQuestion4 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID4 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID4 = QuestionID
END

BEGIN
SET @ReturnQuestion5 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID5 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID5 = QuestionID
END

BEGIN
SET @ReturnQuestion6 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID6 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID6 = QuestionID
END

BEGIN
SET @ReturnQuestion7 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID7 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID7 = QuestionID
END

BEGIN
SET @ReturnQuestion8 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID8 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID8 = QuestionID
END

BEGIN
SET @ReturnQuestion9 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID9 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID9 = QuestionID
END

BEGIN
SET @ReturnQuestion10 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID10 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID10 = QuestionID
END

BEGIN
SET @ReturnQuestion11 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID11 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID11 = QuestionID
END

BEGIN
SET @ReturnQuestion12 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID12 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID12 = QuestionID
END

BEGIN
SET @ReturnQuestion13 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID13 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID13 = QuestionID
END

BEGIN
SET @ReturnQuestion14 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID14 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID14 = QuestionID
END

BEGIN
SET @ReturnQuestion15 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID15 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID15 = QuestionID
END

BEGIN
SET @ReturnQuestion16 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID16 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID16 = QuestionID
END

BEGIN
SET @ReturnQuestion17 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID17 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID17 = QuestionID
END

BEGIN
SET @ReturnQuestion18 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID18 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID18 = QuestionID
END

BEGIN
SET @ReturnQuestion19 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID19 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID19 = QuestionID
END

BEGIN
SET @ReturnQuestion20 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID20 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID20 = QuestionID
END
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11942011
Could you explain what you are trying to with this?  There are a lot of better ways to accomplish this.  What you have shown is very static, and adding new questions, would only make this more and more complicated.

Bob
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:pgilfeather
ID: 11942671
Right,
here goes.

I have a quiz that randomly pulls questions from a datasource via the QuestionID number.

The ID Numbers are pulled into an array before being fed into the parameters that pull the data.

I want to pull 20 Questions onto a web page via these array id numbers but at the moment the questions are not matching up with the multichoice options.

Hope this helps

Regards

PG

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11942695
Are the questions and the options in separate tables?  How are they related?

Bob
0
 

Author Comment

by:pgilfeather
ID: 11942807
They are in separate tables linked by the QuestionID

The columns I want to pull are

Question (from table 1)-----Which sets the question

QuestionOptions(from table 2) ----Which sets the multichoice options

0
 

Author Comment

by:pgilfeather
ID: 11942828
1Question = many QuestionOptions

so 1 to many relationship
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11943030
use a dataadapter to fill two tables in a dataset then setup the relation between the two on the question id ... then you can just use GetChildRows() to get the multiple choice answers for a given question ...

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question