首页上一页 1 下一页尾页 1 条记录 1/1页
asp.net项目开发全程实录第七章
发表在ASP.NET图书答疑
2011-04-07
是否精华
是
否
版块置顶:
是
否
asp.net项目开发全程实录第七章下面是选择单选题和核对单选题答案代码,我想改成自动生成的单选题和核对单选题答案时题号一致,你们已经给我提供了几种方案我也试了,由于刚入门没做成。请老师们能不能根据下面的代码给写出来怎样去实现自动生成
switch (i)
{
//从数据库中选择单选题
case 1:
SqlDataAdapter myadapter1 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='单选题'and que_lessonid='"
+ dd1 + "'and que_taotiid='" + dd2 + "'order by id desc", con);
DataSet myds1 = new DataSet();
myadapter1.Fill(myds1);
DataList1.DataSource = myds1;
DataList1.DataBind();
//生成单选题题号
for (int tID1 = 1; tID1 <= DataList1.Items.Count; tID1++)
{
Label lblSelect = (Label)DataList1.Items[tID1 - 1].FindControl("Label2");
lblSelect.Text = tID1.ToString() + "、";
}
break;
//核对单选题答案
case 3:
SqlDataAdapter myadapter3 = new SqlDataAdapter("select id,que_answer"
+ " from tb_Questions where que_type='单选题'and que_lessonid="
+ dd1 + " and que_taotiid=" + dd2 + " order by id desc", con);
DataSet myds3 = new DataSet();
myadapter3.Fill(myds3);
DataRow[] row1 = myds3.Tables[0].Select();
//计算单选题成
foreach (DataRow answer1 in row1)
{
int_row1 += 1;
if (int_row1<= 3)
{
RadioButtonList rbl = (RadioButtonList)(DataList1.Items[int_row1 - 1].FindControl("RadioButtonList1"));
if (rbl.SelectedValue == "")
{
this.lblSel.Text = "0";
}
else
{
if (answer1["que_answer"].ToString().Trim() == rbl.SelectedValue.ToString().Trim())
{
int_row1Point += 40 / DataList1.Items.Count;
this.lblSel.Text = int_row1Point.ToString();
}
}
}
}
break;