ds1 = m_bllCK_AllocInDet.GetList(strWhere); int cnt = ds1.Tables[0].Rows.Count; foreach (DataRow dr in ds1.Tables[0].Rows) { int keyid = Convert.ToInt32(dr["AllocInDetID"]); m_bllCK_AllocInDet.Delete(keyid); }可以看出来你Where条件里面是用CK_AllocInID过滤ID,因为你后面加的那个字段是ID,但是你取值的时候取的是AllocInDetID,肯定错了,你应该取CK_AllocInID才对
System.IndexOutOfRangeException: 索引超出了数组界限。
在 FineUIDemo.AllocIn.Grid1_RowCommand(Object sender, GridCommandEventArgs e) 位置 E:\testDP\EmptyProjectNet20\CK_AllocIn.aspx.cs:行号 149
ds1.Tables[0].clear();
myQA.Update();
那就可以写成
string value = dr["AllocInDetID"].ToString();
就是呀,我就觉得这个问题没有那么复杂的。你这个我下班回家试试。
疑问:
dr["AllocInDetID"]. 这个值是一个整形值吗,
哥,试过了,还是不行呢。
DataSet ds1;
string strWhere = "CK_AllocInID = " + id; ds1 = m_bllCK_AllocInDet.GetList(strWhere);
int cnt = ds1.Tables[0].Rows.Count;
foreach (DataRow dr in ds1.Tables[0].Rows)
{
int keyid = Convert.ToInt32(dr["AllocInDetID"]);
m_bllCK_AllocInDet.Delete(keyid);
}报错如下:System.ArgumentException: 列“AllocInDetID”不属于表 ds。
在 System.Data.DataRow.GetDataColumn(String columnName)
在 System.Data.DataRow.get_Item(String columnName)
在 FineUIDemo.AllocIn.Grid1_RowCommand(Object sender, GridCommandEventArgs e) 位置 E:\testDP\EmptyProjectNet20\CK_AllocIn.aspx.cs:行号 148
string strWhere = "CK_AllocInID = " + id;
ds1 = m_bllCK_AllocInDet.GetList(strWhere);
int cnt = ds1.Tables[0].Rows.Count;
foreach (DataRow dr in ds1.Tables[0].Rows)
{
int keyid = Convert.ToInt32(dr["AllocInDetID"]);
m_bllCK_AllocInDet.Delete(keyid);
}可以看出来你Where条件里面是用CK_AllocInID过滤ID,因为你后面加的那个字段是ID,但是你取值的时候取的是AllocInDetID,肯定错了,你应该取CK_AllocInID才对
如果楼主2楼的截图上显示的就是从表的数据,那就改成Convert.ToInt32(dr["CK_AllocInDetID"])