在 Asp.net 中的 Web 表单上显示多项选择题

发布于 2024-09-28 04:30:25 字数 488 浏览 1 评论 0原文

在我的项目中,我有一个返回 Exam 对象的 Web 服务。该对象包含一个属性,该属性返回 Questions[] 数组中的多项选择问题集。 Questions 数组中的每个 Question 对象都包含两个属性:Question 和 ChoiceArray。为了清除这里的代码,

Exam e = service.GetExam(long CenterID);

问题[]问题= e.问题;

foreach(问题中的问题)

{

    string q = question.Question;

    Choice[] choice = question.Choice;

}

我需要知道一种方法,可以将所有这些问题及其选择写入表单。由于我将它们作为数组,因此无法使用 DataList 正确绑定它们。知道如何在表单上和选项选择上显示这些问题及其选择,请获取每个问题所选答案的值。

谢谢。

In my project I have a web service that returns an Exam object. This object contains a property that returns set of multiple choice questions in Questions[] array. Each Question object in Questions array contains two properties, Question and ChoiceArray. To clear things here's the code,

Exam e = service.GetExam(long CenterID);

Questions[] questions = e.Questions;

foreach(Qestion question in questions)

{

    string q = question.Question;

    Choice[] choice = question.Choice;

}

I need to know a way I can all of these question and their choices onto a form. Since I have these as arrays I can not bind them properly using DataList. Any idea how to display these questions and their choices on to the form and on choice selection, get the value of the selected answer for each question back.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栖迟 2024-10-05 04:30:25

您可以使用此方法将数组转换为 List

http://www.dotnetspider.com/resources/19560-Convert-from-string-array-to-list-t.aspx

然后你可以绑定到 RadioButtonList。

You can use this method to convert the array to a List<string>:

http://www.dotnetspider.com/resources/19560-Convert-from-string-array-to-list-t.aspx

You can then bind to a RadioButtonList.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文