从数据访问层填充下拉列表 [英] Populate Dropdown From Data Access Layer

查看:110
本文介绍了从数据访问层填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道从sql数据库表填充UI下拉列表的最佳方法是什么。



最好是在用户界面中每个下拉菜单的数据访问层并使用数据读取器?



我是否从中间层调用此方法然后从中调用此方法UI表单?



如何将返回的数据从数据访问层传递到UI?



谢谢。

Hi, I am wondering what is the best way to populate a UI dropdown from a sql database table.

Is it best to have a specific method in the data access layer for each and every drop down in the UI and use a data reader?

Do I then call this method from the middle layer and then call this from the UI form?

How do I pass the returned data up from the data access layer to the UI?

Thank you.

推荐答案

这取决于您的要求。您可以创建一个存储过程来获取应用程序中的所有下拉数据。并提供单个服务调用sp并返回数据的方法。你可以创建一个名为DropDownList的公共类。它可能看起来像这样。



It depends upon your requirement.You can create a single stored procedure for getting all the drop down data in your application.And a single service method that call the sp and return the data .You can create a common class called DropDownList.Which may look like this

Public Class DropDownList
{
public int DataVlaue{get;set;}
Public string DataText{get;set;}
}


I认为这些文章会告诉您并了解如何根据数据库值更新UI:



带管理实体框架和WCF服务的Silverlight应用程序



并且,



带实体的MVVM Silverlight应用程序框架和WCF服务 [ ^ ]



阅读完这些文章并尝试使用源代码后,请播放如果您有任何其他问题,请随时告诉我。
I think these articles will give you and idea how to update the UI based on database values:

Silverlight Application with Management Entity Framework and WCF Service

And,

MVVM Silverlight Application with Entity Framework and WCF Service[^]

After reading these articles and experimenting with the source code, please feel free to let me know if you have any other questions.


这篇关于从数据访问层填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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