DropDownList

让DropDownList下拉值等于数据库中的值被选中

for (int i = 0; i < ddllevel.Items.Count;i++)
        {
            this.ddllevel.Items[i].Selected = false;
            if (this.ddllevel.Items[i].Text == Convert.ToString(dTable.Rows[0]["fuwulevel"].ToString()))
            {
                this.ddllevel.Items[i].Selected = true;
                break;
            }
        }

获取Repeater内DropDownList的选中项

foreach (RepeaterItem ritem in this.rptDetail.Items)
        {
            DropDownList ddl = ritem.FindControl("ddlist") as DropDownList;
            foreach (ListItem item in ddl.Items)
            {
                //item就是我们选中的项
            }
        }

 

posted @ 2014-02-17 15:54  Liu66~  阅读(255)  评论(0编辑  收藏  举报