如何创建国家的州,城市为dll [英] how to create country's state,city as dll

查看:87
本文介绍了如何创建国家的州,城市为dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一些查询可能会将Country的州,城市创建为dll,以便我们可以引用它并在我们的项目中使用.如果是这样,请回复我该怎么做.

Hi All,

I''ve some queries that is that possible to create Country''s states,cities as a dll sothat we can reference it and use in our project.If it is so Please reply me How to do that.

推荐答案


您可以像这样创建国家/地区下拉菜单,
Hi,
You can create a country droppdown like this,
[ToolboxData("<{0}:CountryDropDownList runat=server></{0}:CountryDropDownList>")]
    public class CountryDropDownList : DropDownList
    {
        public override void DataBind()
        {
            SortedList slCountry = new SortedList();
            string Key = "";
            string Value = "";

            if (UseFirstItem)
            {
                slCountry.Add(FirstItemText, FirstItemValue);
            }

            foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            {
                RegionInfo info2 = new RegionInfo(info.LCID);
                if (!slCountry.Contains(info2.EnglishName))
                {
                    Value = info2.TwoLetterISORegionName;
                    Key = info2.EnglishName;
                    slCountry.Add(Key, Value);
                }
            }
            base.DataSource = slCountry;
            base.DataTextField = "Key";
            base.DataValueField = "Value";
            base.DataBind();

            if (UseFirstItem)
            {
                base.SelectedIndex = base.Items.IndexOf(base.Items.FindByValue(FirstItemValue));
            }
        }

        private string _firstItemText = "Select Country";
        public string FirstItemText
        {
            get { return _firstItemText; }
            set { _firstItemText = value; }
        }

        private string _firstItemValue = "-1";
        public string FirstItemValue
        {
            get { return this._firstItemValue; }
            set { this._firstItemValue = value; }
        }

        private bool _useFirtItem = false;
        public bool UseFirstItem
        {
            get { return this._useFirtItem; }
            set { this._useFirtItem = value; }
        }
    }



您可以从此处 [



You can download this as project(Imgalib.Utility)from here[^] and use as a dll.
Hope this will help.


创建一个数据类,就像在类库程序集中通常要做的那样.将需要从其他程序集中访问的类型和成员设为公共或内部(所有其他均为私有,受保护的内部或内部).

将您的库程序集添加到using程序集的引用中.程序集之间不会有任何障碍;像平常一样使用类型及其成员.名称空间可以相同或不同;这只是方便的问题;但不要忘记适当地限定类型名称.

避免在汇编代码中对数据进行硬编码.始终喜欢从持久性数据源(例如文件或数据库)中读取数据.或者,使用嵌入在装配体中的资源.请勿对数据进行硬编码.

—SA
Create a data class as you would normally do in a class library assembly. Make the type and members you need to access from other assemblies public, or internal (all other being private, protected internal or internal).

Add your library assembly to the references of the using assembly. You won''t have any barriers between assemblies; use the types and their members as you usually do. Name spaces can be the same or different; it''s just the matter of convenience; but don''t forget to qualify type names properly.

Avoid hard-coding data in your assembly code. Always prefer reading data from persistent source of data, such as file or data base. Alternatively, use resources embedded in your assembly. Do not hard-code data.

—SA


这篇关于如何创建国家的州,城市为dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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