62,046
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
BindDataToDataList();
}
}
private void BindDataToDataList()
{
SqlConnection con = db.Createcon();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from LessonQuestion where lessonID=" + Request.QueryString["lessonid"] + "and Status='使用'", con);
DataSet ds = new DataSet();
sda.Fill(ds, "question");
this.DataList1.DataKeyField = "QuestionID";
this.DataList1.DataSource = ds.Tables["question"];
this.DataList1.DataBind();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (DataListItem answer in DataList1.Items)
{
string an = ((TextBox)answer.FindControl("txtMyAnswer")).Text;
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (DataListItem answer in DataList1.Items)
{
string an = ((TextBox)answer.FindControl("txtMyAnswer")).Text;
string qid = ((HiddenField)answer.FindControl("hdQID")).Value;
//根据主键把数据添加到数据库
}
}