Пример #1
0
        protected virtual void LoadItemsFromTable(DropDownTreeItem item, object idValue, DataTable table, bool isStr, string idField, string parentIDField, string txtfiled, string valuefiled)
        {
            string str;

            if (isStr)
            {
                str = "{0} = '{1}'";
            }
            else
            {
                str = "{0} = {1}";
            }
            try
            {
                foreach (DataRow row in table.Select(string.Format(str, parentIDField, idValue)))
                {
                    DropDownTreeItem item2 = new DropDownTreeItem();
                    item2.LoadFromDataRow(row, txtfiled, valuefiled);
                    item.Items.Add(item2);
                    this.LoadItemsFromTable(item2, row[idField], table, isStr, idField, parentIDField, txtfiled, valuefiled);
                }
            }
            catch
            {
                throw new ArgumentException("Table or filed name error!", table.TableName);
            }
        }
Пример #2
0
 public virtual void LoadFromTable(DataTable table, bool isStr, string idField, string parentIDField, string txtfiled, string valuefiled)
 {
     try
     {
         this.Items.Clear();
         foreach (DataRow row in table.Select(string.Format("{0} =0", parentIDField)))
         {
             DropDownTreeItem item = new DropDownTreeItem();
             item.LoadFromDataRow(row, txtfiled, valuefiled);
             this.Items.Add(item);
             this.LoadItemsFromTable(item, row[idField], table, isStr, idField, parentIDField, txtfiled, valuefiled);
         }
     }
     catch
     {
         throw new ArgumentException("Table or filed name error!", table.TableName);
     }
 }