Exemplo n.º 1
0
        public static void BuildComboDistinct(DropDownList zCombo, string TableName, string TextFiledName, string ValueFieldName, string OrderFieldName, string WhereString, string BlankText, string BlankValue)
        {
            ComboSourceFlow cmbFlow = new ComboSourceFlow();
            DataTable dt = cmbFlow.GetSourceDistinct(TableName, TextFiledName, ValueFieldName, OrderFieldName, WhereString);
            if (dt != null)
            {
                zCombo.Items.Clear();
                zCombo.DataSource = dt;
                zCombo.DataTextField = TextFiledName;
                zCombo.DataValueField = ValueFieldName;
                zCombo.DataBind();

                if (BlankText != null || BlankValue != null)
                {
                    ListItem itm = new ListItem(BlankText, BlankValue);
                    zCombo.Items.Insert(0, itm);
                }

            }
        }
Exemplo n.º 2
0
        public static void BuildComboDistinct(ComboBox zCombo, string TableName, string TextFiledName, string ValueFieldName, string OrderFieldName, string WhereString, string BlankText, string BlankValue)
        {
            ComboSourceFlow cmbFlow = new ComboSourceFlow();
            DataTable dt = cmbFlow.GetSourceDistinct(TableName, TextFiledName, ValueFieldName, OrderFieldName, WhereString);
            if (dt != null)
            {
                zCombo.Items.Clear();
                if (BlankText != null || BlankValue != null)
                {
                    DataRow dRow = dt.NewRow();
                    dRow[TextFiledName] = BlankText;
                    dRow[ValueFieldName] = BlankValue;
                    dt.Rows.InsertAt(dRow, 0);
                }

                zCombo.DataSource = dt;
                zCombo.DisplayMember = TextFiledName;
                zCombo.ValueMember = ValueFieldName;

            }
        }