你快到了.你只需要转换DataItem
为DataRowView
,并将其分配给DropDownList
这样 -
protected void myRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var degree_dropdown = e.Item.FindControl("degree_dropdown") as DropDownList; string degreeCode = (string) ((DataRowView) e.Item.DataItem)["degreeCode"]; if (degree_dropdown != null) { degree_dropdown.DataSource = degrees; //a datatable degree_dropdown.DataTextField = "degree"; degree_dropdown.DataValueField = "code"; degree_dropdown.DataBind(); if (degree_dropdown.Items.FindByValue(degreeCode) != null) degree_dropdown.SelectedValue = degreeCode; } } }