#region 初始化下拉列表
public static void InitDDL(string sSQL, DropDownList ddl, string sFieldID, string sFieldName, string sSelectFieldNameValue, bool bAll)
{
string sError = "";
DataTable dt = RB.SqlHelper.RunQuery(CommandType.Text, sSQL, null, out sError);
if (sError.Equals(""))
{
ddl.Items.Clear();
ddl.DataSource = dt;
ddl.DataTextField = sFieldName;
ddl.DataValueField = sFieldID;
ddl.DataBind();
if (bAll) ddl.Items.Insert(0, new ListItem("---请选择---", ""));
if (!sSelectFieldNameValue.Equals("")) ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText(sSelectFieldNameValue));
}
}
public static void InitDDL(object list, DropDownList ddl, string sFieldID, string sFieldName, string sSelectFieldNameValue)
{
ddl.Items.Clear();
ddl.DataSource = list;
ddl.DataTextField = sFieldName;
ddl.DataValueField = sFieldID;
ddl.DataBind();
ddl.Items.Insert(0, new ListItem("请选择", ""));
ddl.SelectedValue = sSelectFieldNameValue; }
#endregion