使用n层架构C#的组合人口 [英] Combo Population using n Tier Architecture C#

查看:73
本文介绍了使用n层架构C#的组合人口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用n层架构,因为我需要填充名为category的组合框。数据库表名称是ItemCategory,字段是categoryID和CategoryName。当我点击我设计中的下拉框时,我需要显示CategoryName中的所有数据。

请帮助我。

Hi,
I am using n tier architecture, in that I need to populate the combo box named category. The database table name is ItemCategory and the fields are categoryID and CategoryName. When I click on the drop down box in my design I need to show all the data inside CategoryName.
Please help me.

推荐答案

希望你使用combox它意味着这是windows应用程序。

看到组合框中的数据绑定没有混淆。当你想在数据库中查看数据库中存在的数据时。你需要在页面加载事件中绑定数据。为此,您需要获取DataSet或DataTable或对象列表中的数据列表。只需从您的图层收集数据(可能是业务层)并绑定到组合框的数据源

Hope so you are using combox it' means this is windows application.
See there is no confusion for databinding in a combobox. When you want see data in combobox which is exists in databse.You need to bind data in page load event. for this you need to get list of data in a DataSet or DataTable or in List of object. Just collect the data from your layer(It may be a business layer) and bind to datasource of combobox
Ex.
private void Page_Load(Object sender,EventArgs e)
{
List<itemcategory> listCategory=objBusinessLayer.GetItemCategories();
cmbItemCategory.DataSource=ListCategory;
cmbItemCategory.DataTextField="CategoryName";
cmbItemCategory.DataValueField="categoryID";
}
</itemcategory>





创建N层架构类的工具 [ ^ ]

N-Tier:Begginer设计应用程序的指南 [ ^ ]


这篇关于使用n层架构C#的组合人口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆