0
我有一個CheckBoxList
,我想使用定義了Text
和Values
的ListItems集合來填充CheckBoxList
。CheckBoxList值被DataBind上的文本覆蓋ASP.NET web表單
var temp = types.Select(x => new ListItem(x["Description"].ToString(), x["TypeCode"].ToString()));
chbox.DataSource = temp;
chbox.DataBind();
在temp
的listItems中有正確的Text
和Value
屬性值,但chbox.DataBind()
後,所有的Value
屬性都填充了Text
屬性值。
因此,如果temp
的listItems中的樣子
Text Value
LetterA A
LetterB B
的listItems中的chbox.Items
樣子
Text Value
LetterA LetterA
LetterB LetterB