绑定ComboBox

   private void BindComboBox()
        {
            //根据省份no获取国家对应中文名称
            var  list = wcf.GetCountryList("", "", "");
            this.cmbCountryNo.DataSource = list;
            this.cmbCountryNo.ValueMember = "No";
            //显示国家中英文
            if (Helper.GlobalVariables.Gi_Language_Type == 1)
            {
                this.cmbCountryNo.DisplayMember = "Name_cn";
            }
            else 
            {
                this.cmbCountryNo.DisplayMember = "Name_en";
            }           

        }


/// <summary>
/// 获取国家列表
/// </summary>
public List<m_country> GetCountryList(string countryNo, string countryNameCN, string countryNameEN)
{
using (var ModelContainer = new ntasystemEntities())
{
var dataRes = from t in ModelContainer.m_country where t.made_dist != "D" select t;
if (!string.IsNullOrEmpty(countryNo))
dataRes = from t in dataRes where t.No == countryNo select t;
if (!string.IsNullOrEmpty(countryNameCN))
dataRes = from t in dataRes where t.Name_cn == countryNameCN select t;
if (!string.IsNullOrEmpty(countryNameEN))
dataRes = from t in dataRes where t.Name_en == countryNameEN select t;
return dataRes.ToList<m_country>();
}
}

 

 

posted @ 2014-11-09 20:06  清空回声  阅读(218)  评论(0)    收藏  举报