我无法在编辑模板的下拉列表中获得预选文本。请看我的代码:
<EditItemTemplate>
<asp:DropDownList ID="droplist" runat="server">
</asp:DropDownList>
</EditItemTemplate>
c# 代码
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
DropDownList droplist = (DropDownList)e.Row.FindControl("droplist");
droplist.DataSource = EquipmentBLL.getunitdrop();
droplist.DataTextField = "UnitName";
droplist.DataValueField = "UnitID";
droplist.DataBind();
droplist.Items.Insert(0, new ListItem(" Select Unit ", "0"));
//droplist.Items.FindByText(unittypetext).Selected = true;
}
}
}
有人能告诉我我应该怎么做才能获得预选的下拉菜单吗?
问候侯赛因