主题:为什么显示的不正确????
Literal lit = new Literal ();
RadioButtonList rabtnlst = new RadioButtonList ();
SqlConnection conn = new SqlConnection ("server=.;database=WebExam;uid=sa;");
conn.Open ();
SqlCommand cmd = new SqlCommand ("select top 2 * from Question",conn);
SqlDataReader dr = cmd.ExecuteReader ();
int num=1;
while(dr.Read() )
{
lit.Text +="
"+num+". "+ dr.GetString(2).ToString ();
rabtnlst.ID = "rabtnlst"+num.ToString ();
rabtnlst.Items .Add ("A. "+ dr.GetString (3).ToString ());
rabtnlst.Items .Add ("B. "+ dr.GetString (4).ToString ());
rabtnlst.Items .Add ("C. "+ dr.GetString (5).ToString ());
rabtnlst.Items .Add ("D. "+ dr.GetString (6).ToString ());
for(int i=1;i<=4;i++)
{
rabtnlst.Items [i-1].Value =i.ToString ();
}
Panel1.Controls .Add (lit);
Panel1.Controls .Add (rabtnlst);
num++;
}
conn .Close ();
上面表是个试题表,全是选择题
我想显示试题
就像考试时那样
但这个显示出来的是,把所有问题显示出来了
再显示选项
为什么
怎么改呀???
RadioButtonList rabtnlst = new RadioButtonList ();
SqlConnection conn = new SqlConnection ("server=.;database=WebExam;uid=sa;");
conn.Open ();
SqlCommand cmd = new SqlCommand ("select top 2 * from Question",conn);
SqlDataReader dr = cmd.ExecuteReader ();
int num=1;
while(dr.Read() )
{
lit.Text +="
"+num+". "+ dr.GetString(2).ToString ();
rabtnlst.ID = "rabtnlst"+num.ToString ();
rabtnlst.Items .Add ("A. "+ dr.GetString (3).ToString ());
rabtnlst.Items .Add ("B. "+ dr.GetString (4).ToString ());
rabtnlst.Items .Add ("C. "+ dr.GetString (5).ToString ());
rabtnlst.Items .Add ("D. "+ dr.GetString (6).ToString ());
for(int i=1;i<=4;i++)
{
rabtnlst.Items [i-1].Value =i.ToString ();
}
Panel1.Controls .Add (lit);
Panel1.Controls .Add (rabtnlst);
num++;
}
conn .Close ();
上面表是个试题表,全是选择题
我想显示试题
就像考试时那样
但这个显示出来的是,把所有问题显示出来了
再显示选项
为什么
怎么改呀???