Reputation: 97
Here ab.ABNumber
is counting from the 1st row of dataset And dr["ABNumber"].ToString()
is counting from last row. For that my condition is always mismatched. How can I do it for matched with my condition.
public bool EmailAuthorization(ABMaster ab)
{
string ids = string.Empty;
DataSet ds = new DataSet();
ds= new ABMasterService().LoadAllMDPendingAuthorization(ab.ID);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (ab.ABNumber == dr["ABNumber"].ToString())
{
if (ids.Length > 0)
{
ids += ",";
}
ids += ab.ABNumber;
}
}
}
Upvotes: 0
Views: 81
Reputation: 416
If ab.ABNumber
should really be a string you should compare this strings with Equals
ab.ABNumber.Equals(dr["ABNumber"].ToString())
Upvotes: 1