数据加载如何获取DropDownList中的默认选项,这里就要用到DropDownList.SelectIndex这个属性了.
DropDownList4.Items.Clear();
DropDownList4.Items.Add("商品A类");
DropDownList4.Items.Add("商品B类");
DropDownList4.Items.Add("商品C类");
//DropDownList4.Text = dr["com_kind"].ToString();
if (dr["com_kind"].ToString().Trim() == "商品A类")
{
DropDownList4.SelectedIndex = 0;
}
if (dr["com_kind"].ToString().Trim() == "商品B类")
{
DropDownList4.SelectedIndex = 1;
}
if (dr["com_kind"].ToString().Trim() == "商品C类")
{
DropDownList4.SelectedIndex = 2;
}
写在这里,免得以后忘了.呵呵