如何在下载列表asp.net中显示数据库中的值 [英] how to display value from database in drop down list asp.net
本文介绍了如何在下载列表asp.net中显示数据库中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请给出一个解决方案....
谢谢
121ss
please give a solution for that....
Thanks
121ss
推荐答案
请让我谷歌为你 [ ^ ]。
你可以使用Google搜索
尝试这个简单的代码..
You could have googled
try this simple code..
DataTable dt = new DataTable();
string connectionString = "your connetion string";
SqlConnection con = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter("SELECT DisplayNameColumn,ValueNameColumn FROM TableName", con);
adapter.Fill(dt);
DropDownList1.DataTextField = "DisplayNameColumn";
DropDownList1.DataValueField = "ValueNameColumn";
DropDownList1.DataSource = dt;
DropDownList1.DataBind();
这篇关于如何在下载列表asp.net中显示数据库中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文