using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OAModels;
using OABLL;public partial class admin_ShowUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindTreeView();
}
}
//用于动态绑定树的方法
private void BindTreeView()
{
IList<BranchInfo> branchInfo = BranchInfoManager.GetALLBranchInfo();
foreach (BranchInfo bi in branchInfo)
{
TreeNode fatherNodes = new TreeNode();
fatherNodes.Text = bi.BranchName;
fatherNodes.Value = null;
fatherNodes.ImageUrl = "images/menuclose.gif"; //向树加根节点
this.TreeView1.Nodes.Add(fatherNodes);
////NEW支节点实例
IList<DepartInfo> depaertInfoChild = TreeNodeManager.GetDepartInfoChildNodesBySql(bi.BranchId); foreach (DepartInfo diChild in depaertInfoChild.DepartInfo)
{
................
运行报错为IList<OAModels.BranchInfo>不包含"GetEnumerator"的公共定义因此foreach语句不能作用于IList<OAModels.BranchInfo>类型变量
IList<OAModels.DepartInfo>不包含不包含"GetEnumerator"的公共定义因此foreach语句不能作用于IList<OAModels.DepartInfo>类型变量
我该怎么改,谢谢,问题解决立刻结贴,望指教
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OAModels;
using OABLL;public partial class admin_ShowUser : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindTreeView();
}
}
//用于动态绑定树的方法
private void BindTreeView()
{
IList<BranchInfo> branchInfo = BranchInfoManager.GetALLBranchInfo();
foreach (BranchInfo bi in branchInfo)
{
TreeNode fatherNodes = new TreeNode();
fatherNodes.Text = bi.BranchName;
fatherNodes.Value = null;
fatherNodes.ImageUrl = "images/menuclose.gif"; //向树加根节点
this.TreeView1.Nodes.Add(fatherNodes);
////NEW支节点实例
IList<DepartInfo> depaertInfoChild = TreeNodeManager.GetDepartInfoChildNodesBySql(bi.BranchId); foreach (DepartInfo diChild in depaertInfoChild.DepartInfo)
{
................
运行报错为IList<OAModels.BranchInfo>不包含"GetEnumerator"的公共定义因此foreach语句不能作用于IList<OAModels.BranchInfo>类型变量
IList<OAModels.DepartInfo>不包含不包含"GetEnumerator"的公共定义因此foreach语句不能作用于IList<OAModels.DepartInfo>类型变量
我该怎么改,谢谢,问题解决立刻结贴,望指教
解决方案 »
- 网站屏蔽鼠标右键问题,在线等,急!
- FF下面,如何获取DIV的实际高度
- 求个正则
- 下拉式列表框
- 再次郁闷的提问,关于发布和vs2005的用户角色管理数据库。
- 给个条件在帮定Reperter控件时根据条件改变当前行的颜色怎么做高人近来指点一下
- String和string有什么不同?
- 顶者有分.关于sharepoint2003 portal server的问题...
- 我在asp.net编网页时,有一个问题,请高手帮帮忙
- js document.all和document.form.elements有什么区别吗?
- 应用程序和数据库连接的问题,请大家给予帮助,谢谢!
- windows mobile手机上的IE问题
/// <summary>
/// Ilist<T> 转换成 DataTable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="i_objlist"></param>
/// <returns></returns>
public static DataTable ConvertToDataTable<T>(IList<T> i_objlist)
{
if (i_objlist == null || i_objlist.Count <= 0)
{
return null;
}
DataTable dt = new DataTable(typeof(T).Name);
DataColumn column;
DataRow row; System.Reflection.PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); foreach (T t in i_objlist)
{
if (t == null)
{
continue;
} row = dt.NewRow(); for (int i = 0, j = myPropertyInfo.Length; i < j; i++)
{
System.Reflection.PropertyInfo pi = myPropertyInfo[i]; string name = pi.Name; if (dt.Columns[name] == null)
{
column = new DataColumn(name, pi.PropertyType);
dt.Columns.Add(column);
} row[name] = pi.GetValue(t, null);
} dt.Rows.Add(row);
}
return dt;
}
#endregion