I have to add all the Id from the dataset that has Status value same as “Active” to the int array PromotionID. How is that possible. What am i missing?
int[] promotionID;
foreach (DataRow dr in ds.Tables[0].Rows[i]["Status"].ToString() == "Active")
{
promotionID = new int[] { Convert.ToInt32(dr["Id"]) };
}
The error is:
foreach statement cannot operate on variables of type ‘bool’ because ‘bool’ does not contain a public definition for ‘GetEnumerator’
You’ll want something like this: