mysql diopdownlist连接数据库
#region DropDownList 绑定
protected void DropDownListBind()
{
string sql = "select *from tb_application";
Common comn = new Common();
DataSet ds = comn.GetDataSet(sql);
ddlChapChoice.DataSource = ds.Tables[0].DefaultView;
ddlChapChoice.DataTextField = "course";
ddlChapChoice.DataValueField = "qid";
ddlChapChoice.DataBound();
}
#endregion
表是tb_application 要的字段是course 我这样写错的 该怎么写呢? 主键是qid
------解决方案--------------------
protected void DropDownListBind()
{
string sql = "select *from tb_application";//空一格 select * from tb_application
Common comn = new Common();
DataSet ds = comn.GetDataSet(sql);
ddlChapChoice.DataSource = ds.Tables[0].DefaultView;
ddlChapChoice.DataTextField = "course";
ddlChapChoice.DataValueField = "qid";
ddlChapChoice.DataBound();
}