我在 .aspx 页面上有一个空的列表框
lstbx_confiredLevel1List
我在程序中生成了两个列表
List<String> l1ListText = new List<string>(); //holds the text
List<String> l1ListValue = new List<string>();//holds the value linked to the text
我想在.aspx页面上加载lstbx_confiredLevel1List
列表框和上述数值及文本。所以我正在进行以下操作:
lstbx_confiredLevel1List.DataSource = l1ListText;
lstbx_confiredLevel1List.DataTextField = l1ListText.ToString();
lstbx_confiredLevel1List.DataValueField = l1ListValue.ToString();
lstbx_confiredLevel1List.DataBind();
但是它没有使用l1ListText和l1ListValue加载lstbx_confiredLevel1List。有什么想法吗?
using System.Collections.Generic;
而在第二种方法中使用ToDictionary
你还需要using System.Linq;
。 - Tim Schmelter