0

在将数据集绑定到网格视图之前,我需要修改它。
当我浏览完整的代码块并将鼠标悬停在 dsEmployeeOrg 上时,该记录似乎没有被修改。我在这里想念什么?

我的代码是:

                DataSet dsEmployeeOrg = eCorporateStaffMgr.GetEmployeeAccessLevel(oEmp);
                DataTable dt = dsEmployeeOrg[0];

                string sManagerID = "";
                string sSupervisorID = "";
                string sEmployeeID = "";

                for (int i = 0; i < dsEmployeeOrg.Tables[0].Rows.Count; i++)
                {
                    sManagerID = dt.Rows[i].ItemArray[3].ToString().Trim();
                    sSupervisorID = dt.Rows[i].ItemArray[4].ToString().Trim();
                    sEmployeeID = dt.Rows[i].ItemArray[5].ToString().Trim();

                    if ((sManagerID.ToString().Trim() != sSupervisorID.ToString().Trim()) && (sManagerID.ToString().Trim() != sEmployeeID.ToString().Trim()))
                    {
                        if (sSupervisorID.ToString().Trim() == sEmployeeID.ToString().Trim())
                        {
                            // This is a Supervisor record
                            dt.Rows[i].ItemArray[2] = "1111";
                        }
                        else if (sSupervisorID.ToString().Trim() != sEmployeeID.ToString().Trim())
                        {
                            //This is a Employee record
                            dt.Rows[i].ItemArray[2] = "0000";
                        }
                    }
                }
4

1 回答 1

1

请修改您的代码如下

DataSet dsEmployeeOrg = eCorporateStaffMgr.GetEmployeeAccessLevel(oEmp);
DataTable dt = dsEmployeeOrg[0];
string sManagerID = "";
string sSupervisorID = "";
string sEmployeeID = "";

for (int i = 0; i < dsEmployeeOrg.Tables[0].Rows.Count; i++)
{
   sManagerID = dt.Rows[i].ItemArray[3].ToString().Trim();
   sSupervisorID = dt.Rows[i].ItemArray[4].ToString().Trim();
   sEmployeeID = dt.Rows[i].ItemArray[5].ToString().Trim();

   if ((sManagerID.ToString().Trim() != sSupervisorID.ToString().Trim()) && (sManagerID.ToString().Trim() != sEmployeeID.ToString().Trim()))
   {
       if (sSupervisorID.ToString().Trim() == sEmployeeID.ToString().Trim())
       {
          // This is a Supervisor record
          dt.Rows[i][2] = "1111";
       }
       else if (sSupervisorID.ToString().Trim() != sEmployeeID.ToString().Trim())
       {
          //This is a Employee record
          dt.Rows[i][2] = "0000";
       }
   }
}
于 2012-10-18T22:07:01.703 回答