如何使用实体框架将数据绑定到下拉列表 [英] How to bind data to dropdown using entity framework

查看:63
本文介绍了如何使用实体框架将数据绑定到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ddlCountryDropdown,它显示国家/地区名称。我有表tblCountry,它有库存名称CountryName,我想在页面加载事件时绑定到ddlCountryDropdown。我创建了一个文件夹DTO,我添加了类文件MasterDTO.Cs,我使用实体框架编写了beloqw代码。



i have ddlCountryDropdown which display country name. I have table tblCountry which has coulmn name CountryName which i want to bind to ddlCountryDropdown at page load event.I am create one folder DTO in that i add class file MasterDTO.Cs in that i write beloqw code using entity framework.

public List<tblCountry> GetCountries()
       {

           List<tblCountry> d = null;
           using (var context = new HealthEntities())
           {
               d = context.tblCountries
                   .ToList<tblCountry>();

           }

           return d;
       }



在Default.aspx.cs中如何绑定ddlCountryDropdown。


In Default.aspx.cs how can i bind ddlCountryDropdown.

推荐答案

你可以随时使用谷歌查找这些基本问题的答案..这将有助于节省您和我们的时间检查这里 [ ^ ]
You can always use google to find answers to these basic questions.. This will help save your and our time Check here[^]


这篇关于如何使用实体框架将数据绑定到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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