日期:2014-05-17 浏览次数:20483 次
/// <summary>
/// 绑定DownList 设置text跟value 没有-请选择-
/// </summary>
/// <param name="TableName">表名(可以加条件)</param>
/// <param name="MyDDL">需要绑定的DownList</param>
/// <param name="TextStr">text的字段</param>
/// <param name="ValueStr">value的字段</param>
public static void BindDropDownList(string TableName, DropDownList MyDDL, string TextStr, string ValueStr)
{
string sql = "select * from " + TableName;
MyDDL.Items.Clear();
SqlDataReader dr = DbHelperSQL.GetDataReader(sql);
while (dr.Read())
{
ListItem MyItem = new ListItem();
MyItem.Text = dr[TextStr].ToString();
MyItem.Value = dr[ValueStr].ToString();
MyDDL.Items.Add(MyItem);
}
dr.Close();
}
dosoft.BLL.BaseBLL.BindDropDownList("xt_tc_Plant", dropdownlist1, "name", "id");