如何在C#中使用数据库中的值填充ListBox?
您可以使用任何ORM(例如Linq to SQL,Entity Framework或NHibernate-取决于您的需求和应用程序的规模)来从数据库中读取对象,然后只需将对象的属性作为项添加到列表框。
prepare the List<Object>
for your database records. create the dynamic ListBox control. add control on your page by :
LixtBox lstBox=new ListBox();
lstBox.Datasource=//your List<object>
//Assign datamembers and value members.
Page.Controls.Add(ListBoxControl)
Hope this helps
Take a look at ADO.NET framework but there is a lot of ways to do that...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.