i have a survey page with mixed type of questions having radio buttons and checkboxes . this data is displayed from db.
Question table has all questions and answer table has multiple answers against each Questionid
how to insert a question in db having sub question and selection exactly like the image shown in this link
https://www.snapsurveys.com/blog/snap-survey-software-howto-format-grid-question-online-survey/
how to code in mvc using ef to display in the above link format
CREATE TABLE [dbo].[QuizQuestionarie](
[QuestionID] [int] IDENTITY(1,1) NOT NULL,
[Text] [varchar](500) NULL,
[Radioorcheck] [varchar](10) NULL,
CONSTRAINT [PK_QuizQuestionarie] PRIMARY KEY CLUSTERED
(
[QuestionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[QuizQuestionarie] ON
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (1, N'Are you a male or a female??', N'R')
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (2, N'What is your age?', N'C')
----Other Symptoms -- this is the question heading under which below details will be placed ,atrix format layout
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (3, N'Headache', N'R')
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (4, N'Fever', N'R')
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (5, N'Vomitting', N'R')
INSERT [dbo].[QuizQuestionarie] ([QuestionID], [Text], [Radioorcheck]) VALUES (6, N'Diziness', N'R')
SET IDENTITY_INSERT [dbo].[QuizQuestionarie] OFF
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Answers](
[AID] [int] IDENTITY(1,1) NOT NULL,
[QuestionID] [int] NOT NULL,
[Text] [varchar](500) NULL,
CONSTRAINT [PK_Answers] PRIMARY KEY CLUSTERED
(
[AID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Answers] ON
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (1, 1, N'Male')-- radio button
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (2, 1, N'Female')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (5, 2, N'9-13')-- checkbox
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (6, 2, N'14-17')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (7, 2, N'18-34')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (8, 2, N'35-49')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (9, 2, N'50-64')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (10, 2, N'65-69')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (11, 2, N'70-79')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (12, 2, N'80+')
-- matrix format layout
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (205, 3, N'Never')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (206, 3, N'Seldom')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (207, 3, N'Sometimes')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (208, 3, N'Very rarely')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (211, 3, N'Often')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (212, 4, N'Never')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (213, 4, N'Seldom')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (214, 4, N'Sometimes')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (215, 4, N'Very rarely')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (216, 4, N'Often')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (217, 5, N'Never')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (218, 5, N'Seldom')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (219, 5, N'Sometimes')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (220, 5, N'Very rarely')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (221, 5, N'Often')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (222, 6, N'Never')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (223, 6, N'Seldom')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (224, 6, N'Sometimes')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (225, 6, N'Very rarely')
INSERT [dbo].[Answers] ([AID], [QuestionID], [Text]) VALUES (226, 6, N'Often')
SET IDENTITY_INSERT [dbo].[Answers] OFF
ALTER TABLE [dbo].[Answers] WITH CHECK ADD CONSTRAINT [FK_QuizQuestionarie_QuestionID] FOREIGN KEY([QuestionID])
REFERENCES [dbo].[QuizQuestionarie] ([QuestionID])
GO
ALTER TABLE [dbo].[Answers] CHECK CONSTRAINT [FK_QuizQuestionarie_QuestionID]
GO
ALTER TABLE [dbo].[QuizQuestionarie] WITH CHECK ADD CONSTRAINT [FK_Answers_QuizQuestionarie] FOREIGN KEY([QuestionID])
REFERENCES [dbo].[QuizQuestionarie] ([QuestionID])
GO
ALTER TABLE [dbo].[QuizQuestionarie] CHECK CONSTRAINT [FK_Answers_QuizQuestionarie]
GO