12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Reflection;
- using System.Web.UI;
- namespace Ant.Frame
- {
- public static class GetValue
- {
- public static T GetControlValue<T>(Control page, T enty)
- {
- List<Control> conlist = new List<Control>();
- foreach (Control ctrol in page.Controls)
- {
- conlist.Add(ctrol);
- }
- return GetCollection(conlist, enty, "");
- }
- public static T GetControlValue<T>(Control page, T enty, string lbl)
- {
- List<Control> conlist = new List<Control>();
- foreach (Control ctrol in page.Controls)
- {
- conlist.Add(ctrol);
- }
- return GetCollection(conlist, enty, lbl);
- }
- /// <summary>
- ///不知道控件的级次进行赋值
- /// </summary>
- /// <param name="pages"></param>
- /// <param name="enty"></param>
- public static T GetControlValue<T>(List<Control> pages, T enty)
- {
- return GetCollection(pages, enty, "");
- }
- private static T GetCollection<T>(List<Control> page, T enty, string lbl)
- {
- int level = 0;
- return ControlCollection(page, level, enty, lbl);
- }
- private static T ControlCollection<T>(List<Control> oldMenus, int level, T entity, string lbl)
- {
- foreach (Control menu in oldMenus)
- {
- SelectControl con = new SelectControl(ControlType.Ext, menu);
- entity = con.GetResult<T>(entity, lbl);
- int controlnum = menu.Controls.Count;
- if (controlnum == 0)
- level++;
- else
- {
- List<Control> conlist = new List<Control>();
- foreach (Control ctrol in menu.Controls)
- {
- conlist.Add(ctrol);
- }
- ControlCollection<T>(conlist, level, entity, lbl);
- }
- }
- return entity;
- }
- }
- }
|