本文介绍了绑定下拉列表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从sql server绑定dropdownlist中的数据.
i want to bind the data in dropdownlist from sql server
推荐答案
private void dropdownlistbind()
{
SqlCommand cmd = new SqlCommand("Your Command using appropriate clause","Your Connection");
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataSource = ds;
// FieldName of Table in DataBase
DropDownList1.DataValueField = "FieldName";
DropDownList1.DataBind();
}
这篇关于绑定下拉列表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!