Exemple #1
0
        public static void BindDropDownList(DataTable dt, DropDownListAjaxHelper ddl, string textField, string valueField, string sort, string filter, string selectedValue, string firstTitle = null)
        {
            DataView dv  = dt.DefaultView;
            string   srt = dv.Sort;
            string   flt = dv.RowFilter;

            if (!String.IsNullOrEmpty(sort) && srt != sort)
            {
                dv.Sort = sort;
            }
            if (!String.IsNullOrEmpty(filter))
            {
                dv.RowFilter = filter;
            }
            if (!String.IsNullOrEmpty(firstTitle))
            {
                dv[0][textField] = firstTitle;
            }

            ddl.DataSource(dt.DefaultView, valueField, textField);
            if (selectedValue != null)
            {
                ddl.SelectedValue(selectedValue);
            }

            dt.RejectChanges();
            dv.Sort      = srt;
            dv.RowFilter = flt;
        }
Exemple #2
0
        public static void BindDropDownList(DropDownListAjaxHelper ddl, string text = "-请选择-")
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("dm", Type.GetType("System.String"));
            dt.Columns.Add("mc", Type.GetType("System.String"));
            dt.Rows.Add(new string[] { "__", text });

            ddl.DataSource(dt.DefaultView, "dm", "mc");
        }
Exemple #3
0
        public static void BindDropDownList(DataTable dt, DropDownListAjaxHelper ddl, string textField, string valueField, string sort = null, string selectedValue = null)
        {
            string srt = dt.DefaultView.Sort;

            if (!String.IsNullOrEmpty(sort) && srt != sort)
            {
                dt.DefaultView.Sort = sort;
            }

            ddl.DataSource(dt.DefaultView, valueField, textField);
            if (selectedValue != null)
            {
                ddl.SelectedValue(selectedValue);
            }

            if (!String.IsNullOrEmpty(sort) && srt != sort)
            {
                dt.DefaultView.Sort = srt;
            }
        }