简体   繁体   English

如何将大容量数据从数据库表填充到组合框? -C#.NET

[英]How Can i Populate Bulk of Data from a DB Table into a Combo Box? - C#.NET

MenuItem menus = new MenuItem();
GridView1.DataSource = menus.GetDataTable();
GridView1.DataBind();

menus.GetDataTable() returns a DataTable. menus.GetDataTable()返回一个DataTable。 In the above case, we are returning to GridView. 在上述情况下,我们将返回到GridView。 I need to populate the data into a combo box. 我需要将数据填充到组合框中。 How can i do it? 我该怎么做?

NOTE: Assume GetDataTable only returns records of a single column. 注意:假定GetDataTable仅返回单个列的记录。

I'm using Winforms 我正在使用Winforms

检查这是否对您有帮助。

Solution is: 解决方法是:

    Country countryName = new Country();
    comCountryCus.DataSource = countryName.GetDataFromTable();
    comCountryCus.DisplayMember = "CountryName";

http://msdn.microsoft.com/en-us/library/w67sdsex%28v=VS.80%29.aspx http://msdn.microsoft.com/zh-CN/library/w67sdsex%28v=VS.80%29.aspx

KISS - Keep It Simple & Stupid. 吻-保持简单和愚蠢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM