Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 我在parentmodule id处出错,我的Allnode集合计数为19,我在循环中的计数为15处出错_C# 4.0 - Fatal编程技术网

C# 4.0 我在parentmodule id处出错,我的Allnode集合计数为19,我在循环中的计数为15处出错

C# 4.0 我在parentmodule id处出错,我的Allnode集合计数为19,我在循环中的计数为15处出错,c#-4.0,C# 4.0,在icount 15上调试时,我的集合大小为19 count。索引超出范围时显示错误。必须为非负数且小于集合的大小。 参数名称:索引 下面是我的代码 public void PopulateTreeView(DataTable dt) { int iCount = dt.Rows.Count; TreeNode ModuleList = new TreeNode(); Collection<TreeNode> AllNode =

在icount 15上调试时,我的集合大小为19 count。索引超出范围时显示错误。必须为非负数且小于集合的大小。 参数名称:索引 下面是我的代码

public void PopulateTreeView(DataTable dt)
    {
        int iCount = dt.Rows.Count;
        TreeNode ModuleList = new TreeNode();
        Collection<TreeNode> AllNode = new Collection<TreeNode>();
        TreeNode finalNode = new TreeNode();
        Collection<string> nodeID = new Collection<string>();

        for (int icount = 0; icount < dt.Rows.Count; icount++)
        {
            TreeNode CurNode = new TreeNode(dt.Rows[icount]["ResDsc"].ToString(), dt.Rows[icount]["ModuleID"].ToString());
            CurNode.NavigateUrl = "javascript:void(0)";
            AllNode.Add(CurNode);
            nodeID.Add(dt.Rows[icount]["ModuleID"].ToString());

            if (dt.Rows[icount]["AccessStatus"].ToString() != "0")
            { CurNode.Checked = true; }
            else { CurNode.Checked = false; }
        }

        TrVUser.Nodes.Clear();
        for (int icount = 0; icount < dt.Rows.Count; icount++)
        {
            TreeNode CurNode = AllNode[nodeID.IndexOf(dt.Rows[icount]["ModuleID"].ToString())];
            CurNode.NavigateUrl = "javascript:void(0)";
            if (dt.Rows[icount]["ParentModuleID"].ToString() != "")
                AllNode[nodeID.IndexOf(dt.Rows[icount]["ParentModuleID"].ToString())].ChildNodes.Add(CurNode);
            else
                TrVUser.Nodes.Add(CurNode);
        }

        TrVUser.ExpandAll();

        DataTable dtt = null;
        string UserGroupGrp = null;

        //select all the user group have been selected
        if (Request.QueryString["userid"] != null)
        {
            userid = Request.QueryString["userid"].ToString();

            //DataSet dsPopulateTree = new DataSet();
            //Hashtable ht = new Hashtable();
            //ht.Add("@UserID", Request.QueryString["UserID"].ToString());
            //dsPopulateTree = objDAL.GetDataSetForPrc("Prc_ModuleTreeView", ht);
            //comment by pallavi

            string strSQL = "SELECT Distinct UserGroupCode FROM iUserGrpAcs b left join iModule  on (b.ModuleID = iModule.ModuleID)";
            strSQL += " WHERE (UserId = '" + userid + "')";

            DataSet ds1 = oDP.ReadData("DefaultConn", strSQL);
            dtt = ds1.Tables[0];
        }

        for (int icount = 0; icount < dtt.Rows.Count; icount++)
        {
            UserGroupGrp += dtt.Rows[icount]["UserGroupCode"].ToString() + ";";
        }
        lblUserGroupGrp.Text = UserGroupGrp;
    }

    
public void PopulateTreeView(数据表dt)
{
int iCount=dt.Rows.Count;
TreeNode ModuleList=新的TreeNode();
Collection AllNode=new Collection();
TreeNode finalNode=新的TreeNode();
集合nodeID=新集合();
对于(int-icount=0;icount
在icount 15上调试时,我的集合大小为19 count。索引超出范围时显示错误。必须为非负数且小于集合的大小。 参数名称:索引

请帮帮忙