我有一个CheckBoxList我想使用 ListItems 的集合来填充Text并Values定义的。
var temp = types.Select(x => new ListItem(x["Description"].ToString(), x["TypeCode"].ToString()));
chbox.DataSource = temp;
chbox.DataBind();
中的 ListItemstemp具有正确的Text属性Value值,但在 之后chbox.DataBind(),所有Value属性都填充了Text属性值。
所以如果 ListItemstemp看起来像
Text Value
LetterA A
LetterB B
ListItemschbox.Items看起来像
Text Value
LetterA LetterA
LetterB LetterB