Dictionary的使用(给Dropdownlist做固定数据)

Dictionary<string, string> droplistds= new Dictionary<string, string>();
            droplistds.Add("1", "China");
            droplistds.Add("2", "USA");
            droplistds.Add("3", "Canada");
            droplistds.Add("4", "Japan");

            dropdownlist1.DataSource = droplistds;
            dropdownlist1.DataValueField = "Key";
            dropdownlist1.DataTextField = "Value";
            dropdownlist1.DataBind();

posted on 2008-07-16 13:32  秋天  阅读(489)  评论(0编辑  收藏  举报

导航