在三层架构下,GridView里编辑一个 DropDownList,后台代码怎么写,才能显示数据
展开全部
private void bind()
{
try
{
DataTable dt = new DataTable();
string sql = “select * from table”;
dt = BLL.Instance.getBySql(sql);//getBySql就是一个按SQL语句查询的方法 你自己写 可以返回DataTable 也可以List
DropPro.DataSource = dt;
DropPro.DataTextField = "name";
DropPro.DataValueField = "ID";
DropPro.DataBind();
DropPro.ClearSelection();
DropPro.Items.Insert(0, "--选择省市--");
}
catch
{
}
}
{
try
{
DataTable dt = new DataTable();
string sql = “select * from table”;
dt = BLL.Instance.getBySql(sql);//getBySql就是一个按SQL语句查询的方法 你自己写 可以返回DataTable 也可以List
DropPro.DataSource = dt;
DropPro.DataTextField = "name";
DropPro.DataValueField = "ID";
DropPro.DataBind();
DropPro.ClearSelection();
DropPro.Items.Insert(0, "--选择省市--");
}
catch
{
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询