我正在循环2个Datagrids并获取所选人员的IndividualID(PrimaryKeys)。我调试了这个,循环工作正常。当我从表适配器调用我的更新方法时,似乎没有任何事情发生。它没有更新。这是我的代码。不确定我做错了什么:
protected void imgbtnReassgin_Click(object sender, ImageClickEventArgs e)
{
foreach (GridViewRow row in gvAdminCustomer.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("chkitemSelectorCustomers");
if (cb != null && cb.Checked)
{
int oIndividualID = Convert.ToInt32((gvAdminCustomer.DataKeys[row.RowIndex].Value));
// GlobalVar.oIndividualID = oIndividualID;
foreach (GridViewRow r in gvReassignCustomers.Rows)
{
CheckBox chkBox = (CheckBox)row.FindControl("chkitemSelectorAllManagersandSalesman");
if (chkBox != null && chkBox.Checked)
{
int oNewParentID = Convert.ToInt32((gvReassignCustomers.DataKeys[r.RowIndex].Value));
individualTableAdapter ind = new individualTableAdapter();
//Individual ind = new Individual();
ind.reassign_Individual(oIndividualID, oNewParentID);
}
}
gvAdminCustomer.DataBind();
}
}
}
答案 0 :(得分:1)
是否更新数据库记录而不反映在网格上?如果是这种情况,那么看起来它只是使用它在循环之前使用的数据源重新绑定网格。您需要刷新数据集然后重新绑定:
gvAdminCustomer.DataSource = YourDataSource;
gvAdminCustomer.DataBind();
祝你好运!