首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DataTable 零处没有任何行

2013-07-08 
DataTable0处没有任何行 private DataTable GetSelIDlists(){DataTable dt new DataTable()bool IsChec

DataTable 0处没有任何行

 

private DataTable GetSelIDlists()
        {
 
            DataTable dt = new DataTable();
            bool IsCheck = false;
            int count = this.PdGridView.RowCount;
            for (int i = 0; i < count; i++)
            {
                if ((bool)(((DataGridViewCheckBoxCell)this.PdGridView.Rows[i].Cells[0]).EditedFormattedValue) == true)
                {
                    dt.Rows[i][0] = this.PdGridView.Rows[i].Cells["pname"].Value.ToString();
                    dt.Rows[i][1] = this.PdGridView.Rows[i].Cells["pmade"].Value.ToString();
                    dt.Rows[i][2] = this.PdGridView.Rows[i].Cells["poutprice"].Value.ToString();
                    dt.Rows[i][3] = this.PdGridView.Rows[i].Cells["Column1"].Value.ToString();
                    dt.Rows[i][4] = this.PdGridView.Rows[i].Cells["spname"].Value.ToString();
                    dt.Rows[i][5] = this.PdGridView.Rows[i].Cells["flag"].Value.ToString();
                    dt.Rows[i][6] = "1";
                    dt.Rows[i][7] = this.PdGridView.Rows[i].Cells["flag"].Value.ToString();
                    IsCheck = true;
                }
 
            }


            if (IsCheck == false)
            {
                dt = null;
            }
            return dt;
        }



我上面的代码实现的是在A窗体的里面的一个Gridview表选择数据,然后把数据赋值给DataTable表,我选择第一行的数据点击一个button就是提示《0处没有任何行》?


DataTable    零处没有任何行
[解决办法]
不要紧接着问“那么如何修改啊?”这类问题。别人不一定有时间在最基础的编程知识上给你从学校里的知识讲起,你一旦知道问题出在哪里,那么应该重新自学,自己记住以后如何判断问题的原因,自己找到正确的程序设计方法才是真的学会了。而不是总是问“那么该如何修改啊?”。
[解决办法]
你根本都没定义DataTable的行列

热点排行