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处没有任何行》?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货