DateSet取出一行行数据显示在Repeater中
/// <summary>
/// 绑定选择题列表
/// </summary>
private void BindSelectQuestionList() {
ITestDal testDal = Factory.CreateTestDal();
string filter = GetFilter();
DataSet ds = testDal.Get_R_QuesAndAnswer(filter);
hid_r_count.Value = ds.Tables[0].Rows.Count.ToString();
//遍历DataSet中默认第一个表中的行
//foreach (DataRow dr in ds.Tables[0].Rows)
//{
// //获取行中某个字段(列)的数据
// this.ques_repeater.DataSource=(dr.Table.Rows.ToString());
// this.ques_repeater.DataBind();
//}
this.ques_repeater.DataSource = ds;
this.ques_repeater.DataBind();
}
前台界面显示:
<asp:Repeater ID="ques_repeater" runat="server"
onitemdatabound="ques_repeater_ItemDataBound">
<HeaderTemplate><ul class="content"></HeaderTemplate>
<ItemTemplate>
<li>
<div class="tg" style="font-size:13px; font-family:宋体">
<ul class="tg_1">
<%#Eval("num")%>、 <%#Eval("question")%>
</ul>
<ul class="tg_2">