我是用DataList里嵌套RadioButtonList完成一个单选题试题,不知道为什么运行的时候试题总是不显示,谁能帮我看下,请问属性事件里是不是也要设置,最后说详细点,是新手 //============页面加载事件,从数据库中提取题目================
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.getCom(1);
this.getCom(2);
}
}
//==================执行与数据库的关联操作=====================
protected void getCom(int i)
{ string dd1 = null;
if (Application["d1"] != null)
{
dd1 = Application["d1"].ToString();
}
SqlConnection con = dataconn.getcon();
con.Open();
switch (i)
{
//从数据库中选择单选题
case 1:
SqlDataAdapter myadapter1 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='单选题'and que_lessonid='"+dd1
+ "'order by id desc", con);
DataSet myds1 = new DataSet();
myadapter1.Fill(myds1,"tb_Questions");
DataList1.DataSource = myds1;
DataList1.DataBind();
//生成单选题题号
for (int t1 = 1; t1 <= DataList1.Items.Count; t1++)
{
Label lblSelect = (Label)DataList1.Items[t1 - 1].FindControl("Label2");
lblSelect.Text = t1.ToString() + "、";
}
break;
//从数据库中选择判断题
case 2:
SqlDataAdapter myadapter2 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='判断题'and que_lessonid='" + dd1
+ "'order by id desc", con);
DataSet myds2 = new DataSet();
myadapter2.Fill(myds2, "tb_Questions");
DataList2.DataSource = myds2;
DataList2.DataBind();
//生成判断题题号
for (int t2 = 1; t2 <= DataList2.Items.Count; t2++)
{
Label lblDSelect = (Label)DataList2.Items[t2 - 1].FindControl("Label24");
lblDSelect.Text = t2.ToString() + "、";
}
break;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.getCom(1);
this.getCom(2);
}
}
//==================执行与数据库的关联操作=====================
protected void getCom(int i)
{ string dd1 = null;
if (Application["d1"] != null)
{
dd1 = Application["d1"].ToString();
}
SqlConnection con = dataconn.getcon();
con.Open();
switch (i)
{
//从数据库中选择单选题
case 1:
SqlDataAdapter myadapter1 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='单选题'and que_lessonid='"+dd1
+ "'order by id desc", con);
DataSet myds1 = new DataSet();
myadapter1.Fill(myds1,"tb_Questions");
DataList1.DataSource = myds1;
DataList1.DataBind();
//生成单选题题号
for (int t1 = 1; t1 <= DataList1.Items.Count; t1++)
{
Label lblSelect = (Label)DataList1.Items[t1 - 1].FindControl("Label2");
lblSelect.Text = t1.ToString() + "、";
}
break;
//从数据库中选择判断题
case 2:
SqlDataAdapter myadapter2 = new SqlDataAdapter("select * "
+ "from tb_Questions where que_type='判断题'and que_lessonid='" + dd1
+ "'order by id desc", con);
DataSet myds2 = new DataSet();
myadapter2.Fill(myds2, "tb_Questions");
DataList2.DataSource = myds2;
DataList2.DataBind();
//生成判断题题号
for (int t2 = 1; t2 <= DataList2.Items.Count; t2++)
{
Label lblDSelect = (Label)DataList2.Items[t2 - 1].FindControl("Label24");
lblDSelect.Text = t2.ToString() + "、";
}
break;
解决方案 »
- 菜鸟求助!用文件编一个小型公司的人员信息管理系统
- 我要结贴了,来个回答,送分啦,如何设置AxSpreadSheet控件字体等样式
- C# 调用C++API 类型转换的问题
- 大家推荐一下初学者关于linux和C#方面的书。正在考虑要学哪个,给点意见,谢!!!
- c#的结构体类型中,可以有成员函数吗?(c++中是可以有的)
- C#画图求助,努力思考就是不成功,求教求教
- 做过对IIS操作的朋友请帮帮忙
- 怎样在现有DataSet数据集中提取,指定范围的数据?
- 按住鼠标怎么拖动picture控件里的图象?高分!
- 大虾VB.net 怎样写: Panel p = (Panel)FindControl(CurrentPanel);
- 我做个点菜系统 厨房有个网络pos打印机(通过网线连入局域网),怎么把数据发送到那台打印机打印C#语言
- 关于串口通信
应该 string dd1 = Application["d1"].ToString();
另 d1 应定义