当前位置: 代码迷 >> ASP.NET >> 关于联动 CheckBoxList 的小疑点
  详细解决方案

关于联动 CheckBoxList 的小疑点

热度:3058   发布时间:2013-02-25 00:00:00.0
关于联动 CheckBoxList 的小问题
有InfoUser_FolderList 和 InfoUser_FileList 两个checkboxlist,下面的事件是触发InfoUser_FolderList ,选中的项跟InfoUser_FileList 的项联动,但总出现下面错误

C# code
未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 行 864:              #endregion行 865:               // DataSet ds = FileManager_B.GetAllFileByFolderID(int.Parse(InfoUser_FolderList.Items[i].Value));行 866:                for (int j = 0; j < ds_FileList.Tables[0].Rows.Count; j++)行 867:                {行 868:                    for (int k = 0; k < InfoUser_FileList.Items.Count; k++) 



C# code
 protected void InfoUser_FolderList_SelectedIndexChanged(object sender, EventArgs e)    {        for (int i = 0; i < InfoUser_FolderList.Items.Count; i++)        {                     DataSet ds_FileList = FileManager_B.GetAllFileByFolderID(int.Parse(InfoUser_FolderList.Items[i].Value));            if (InfoUser_FolderList.Items[i].Selected)            {                for (int j = 0; j < ds_FileList.Tables[0].Rows.Count; j++)                {                    for (int k = 0; k < InfoUser_FileList.Items.Count; k++)                    {                        if (InfoUser_FileList.Items[k].Value == ds_FileList.Tables[0].Rows[j]["ID"].ToString())                        {                            InfoUser_FileList.Items[k].Selected = true;                        }                    }                }            }            else            {                for (int j = 0; j < ds_FileList.Tables[0].Rows.Count; j++)                {                    for (int k = 0; k < InfoUser_FileList.Items.Count; k++)                    {                        if (InfoUser_FileList.Items[k].Value == ds_FileList.Tables[0].Rows[j]["ID"].ToString())                        {                            InfoUser_FileList.Items[k].Selected = false;                        }                    }                }            }        }    }


------解决方案--------------------------------------------------------
ds_FileList.Tables[0]为null了吧

DataSet ds_FileList = FileManager_B.GetAllFileByFolderID 可能就没有返回数据