绑定下拉列表中的数据 [英] bind data in dropdownlist
本文介绍了绑定下拉列表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从sql server绑定dropdownlist中的数据.
i want to bind the data in dropdownlist from sql server
推荐答案
做到这一点! (如果您有问题,请描述一下,以便我们为您提供实际帮助)
请在此处 [
So do that! (If you have a problem, please describe it so we can actually help you)
Look here[^]here for starters
尝试
Try
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();
}
这篇关于绑定下拉列表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文