Ejemplo n.º 1
0
        /// <summary>
        /// 绑定下拉等列表,控件需要继承自:ListControl。
        /// </summary>
        /// <param name="control">DropDown/CheckBoxList/RadioButtonList等</param>
        /// <param name="where">对表的数据进行过滤如:"ID>15 and Url='cyqdata.com'"</param>
        /// <param name="text">绑定时显示的字段名[默认字段名取自控件的ID(去掉前三个字母前缀)]</param>
        /// <param name="value">绑定时显示字段对应的值[默认值的字段名为:ID]</param>
        public void Bind(object control, object where, object text, object value)
        {
            string     sql    = _SqlCreate.GetBindSql(where, text, value);
            MDataTable mTable = null;

            switch (_DbBase.dalType)
            {
            case DalType.Txt:
            case DalType.Xml:
                NoSqlCommand cmd = new NoSqlCommand(sql, _DbBase);
                mTable = cmd.ExeMDataTable();
                cmd.Dispose();
                break;

            default:
                mTable = _DbBase.ExeDataReader(sql, false);
                // dalHelper.ResetConn();//重置Slave
                break;
            }

            bool result = (mTable != null && mTable.Rows.Count > 0);

            if (result)
            {
                MBindUI.BindList(control, mTable);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 绑定下拉等列表,控件需要继承自:ListControl。
        /// </summary>
        /// <param name="control">DropDown/CheckBoxList/RadioButtonList等</param>
        /// <param name="where">对表的数据进行过滤如:"id>15 and Url='cyqdata.com'"</param>
        /// <param name="text">绑定时显示的字段名[默认字段名取自控件的id(去掉前三个字母前缀)]</param>
        /// <param name="value">绑定时显示字段对应的值[默认值的字段名为:id]</param>
        public void Bind(object control, object where, object text, object value)
        {
            string     sql    = _SqlCreate.GetBindSql(where, text, value);
            MDataTable mTable = _DalBase.ExeDataReader(sql, false);
            bool       result = (mTable != null && mTable.Rows.Count > 0);

            if (result)
            {
                MBindUI.BindList(control, mTable);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 绑定DrowDownList等列表控件
 /// </summary>
 public void Bind(object control, string where)
 {
     Bind(control, where, MBindUI.GetID(control), _Data.Columns.FirstPrimary.ColumnName);
 }