简体   繁体   English

寻找合适的DataBound控件来实现问题页面

[英]Looking for suitable DataBound control to implement questions page

I looking forward to find a suitable asp.net DataBound control (C#) to implement in my application. 我期待在我的应用程序中找到一个合适的asp.net DataBound控件(C#)来实现。

I wanted to create a exam page where each page show 10 questions, each question got a Label control and a radiobutton control to display the choices, the data to be bind into the DataBound control might be having multiple rows where each rows represent each question. 我想创建一个考试页面,其中每个页面显示10个问题,每个问题都有一个Label控件和一个radiobutton控件来显示选项,要绑定到DataBound控件的数据可能有多行,其中每行代表每个问题。

I found that DetailView control was quite suit with my requirement but I not able to set the page size. 我发现DetailView控件非常适合我的要求但我无法设置页面大小。

Please help to give some suggestion and advises, thank you in advanced. 请帮助提出一些建议和建议,谢谢你的进阶。

I would recommend to you to use the Repeater control since you can customize it's design very easily to suit your needs. 我建议您使用Repeater控件,因为您可以非常轻松地自定义它的设计以满足您的需求。

Here are two tutorials on how to use it: 以下是有关如何使用它的两个教程:

http://www.w3schools.com/aspnet/aspnet_repeater.asp http://www.w3schools.com/aspnet/aspnet_repeater.asp

http://www.learn-asp.net/asptutorials/Repeater.aspx http://www.learn-asp.net/asptutorials/Repeater.aspx

Update: 更新:

Repeater doesn't have pagination included so you would have to add it: Repeater没有包含分页,因此您必须添加它:

http://blog.divergencehosting.com/2009/03/25/adding-paging-repeater/ http://blog.divergencehosting.com/2009/03/25/adding-paging-repeater/

Other option would be to just use a GridView which has pagination included. 其他选择是只使用包含分页的GridView。

I would use a DataList or a ListView, because it will allow you to enter a template for each item. 我会使用DataList或ListView,因为它允许您为每个项目输入模板。 The reason I would choose these over a repeater is because you can use data keys, which will probably come in handy. 我在转发器上选择这些的原因是因为你可以使用数据键,这可能会派上用场。

Here's a simple example of how you could implement a list of questions: 这是一个如何实现问题列表的简单示例:

<asp:DataList ID="DataList1" runat="server" DataKeyField="QuestionID" ...>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%#Eval("Question")%>' />
        <asp:RadioButton ID="RadioButton1" runat="server" Text="Yes" GroupName="QuestionAnswer" ... />
        <asp:RadioButton ID="RadioButton2" runat="server" Text="No" GroupName="QuestionAnswer" ... />
    </ItemTemplate>
</asp:DataList>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM