/// <summary> /// 绑定DropDownList /// </summary> /// <param name="dl">DropDownList</param> /// <param name="tArray">TDataEnum[]</param> /// <param name="isManualNoID">是否DataTextField绑定ManualNO</param> /// <param name="isNullBind">是否DropDownList空绑定</param> /// <param name="isFirstEmpty">是否第一个值为空</param> public static void BindEnum(this DropDownList dl, TDataEnum[] tArray, bool isManualNoID, bool isNullBind,bool isFirstEmpty) { if (tArray != null && tArray.Length > 0 && !isNullBind) { dl.DataSource = tArray; dl.DataTextField = isManualNoID ? "ManualNO" : "EnumDataName"; dl.DataValueField = "EnumDataID"; } dl.DataBind(); if (isFirstEmpty) { dl.Items.Insert(0, new ListItem(string.Empty,Guid.Empty.ToString())); dl.SelectedIndex = -1; } }