|
<< Click to Display Table of Contents >> DropDownList - com dictionary |
![]() ![]()
|
aspx
<asp:DropDownList runat="server" ID="DropDownList1" />
cs
Dictionary<string, string> dados = new Dictionary<string, string>();
dados.Add("1", "Exemplo 1");
dados.Add("2", "Exemplo 2");
dados.Add("3", "Exemplo 3");
DropDownList1.DataSource = dados;
DropDownList1.DataTextField = "Key"; ;
DropDownList1.DataValueField = "Value";
DropDownList1.DataBind();