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就是我们选中的项 } }