예제 #1
0
 /// <summary>
 /// 绑定列表框
 /// </summary>
 /// <param name="list">列表框</param>
 /// <param name="textField">显示内容</param>
 /// <param name="valueField"></param>
 /// <param name="strWhere"></param>
 /// <param name="strErrMsg"></param>
 public void GetListBox(System.Web.UI.WebControls.ListBox list, string textField, string valueField, string strWhere, out string strErrMsg)
 {
     list.DataSource     = aedal.GetDropDownList(textField, valueField, strWhere, out strErrMsg);
     list.DataTextField  = textField;
     list.DataValueField = valueField;
     list.DataBind();
 }
예제 #2
0
        //SelectDataBind
        public static void SelectDataBind(System.Web.UI.WebControls.ListBox _listBox, string sqlCommandString, SqlParameter[] parameters, CommandType commandType, string connectionString)
        {
            DataTable dt = SelectTable(sqlCommandString, parameters, commandType, connectionString, null);

            _listBox.DataSource     = dt;
            _listBox.DataTextField  = dt.Columns[1].ColumnName;
            _listBox.DataValueField = dt.Columns[0].ColumnName;
            _listBox.Items.Clear();
            _listBox.DataBind();
        }
예제 #3
0
 public static void BindListbox(ref System.Web.UI.WebControls.ListBox ListBoxControl, DataTable dt, string DataTextField, string DataValueField, params string[] SelectedValues)
 {
     ListBoxControl.DataTextField  = DataTextField;
     ListBoxControl.DataValueField = DataValueField;
     ListBoxControl.DataSource     = dt;
     ListBoxControl.DataBind();
     for (int i = 0; i < SelectedValues.Length; i++)
     {
         for (int j = 0; j < ListBoxControl.Items.Count; j++)
         {
             ListBoxControl.Items[j].Selected = (ListBoxControl.Items[j].Value == SelectedValues[i].ToString());
         }
     }
 }