我在这里有这段代码,我正在尝试将combobox的内容输出到我的标签中。但是我得到一个错误,我不能把char转换成System.Web.UI.WebControls.ListItem
foreach (ListItem mine in ListSitesDropDownBox.Items)
{
Mylabel.Text += mine.Value.ToString() + " " + mine.ToString() + "<br>";
}你建议我怎么做才能输出列表项的值和名称?
谢谢
发布于 2011-02-24 02:06:17
在第二部分中,您需要我的Text属性。
foreach (ListItem mine in ListSitesDropDownBox.Items)
{
Mylabel.Text += mine.Value + " " + mine.Text + "<br>";
}Here's the MSDN reference for ListItem。此外,Value不需要ToString,因为它已经是一个string。
发布于 2011-02-24 01:57:15
为什么要这样做:
ListSitesDropDownBox.ToString()?
只需将其替换为:
ListSitesDropDownBox.Itemshttps://stackoverflow.com/questions/5094854
复制相似问题