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();

你可能感兴趣的:(list)