How to loop each row that readed? in my code, the row won't bind to next row because of the same productID, so the datagridview won't move to new row, it still in the same row and overwrite the price (for some product, i have two price). How to loop it to show the same productID but it have different price.
EX : 1 Hamburger have 2 price
Hamburger : $1 and $2
when i get the data with looping it, the resould shoult be have 2 Row with same product but different price. How to do this? below is my code
productID = odr["product_id"].ToString();
quantity = Double.Parse(odr["quantity"].ToString());
//processing data...
key = productID.ToString();
if (key != key_tmp)
{
//update index...
i++;
//updating variable(s)...
key_tmp = key;
}
if (datagridviews.Rows[i].Cells["qty"].Value != null) //already has value...
{
currJlh = Double.Parse(ddatagridviews.Rows[i].Cells["qty"].Value.ToString());
}
else //not yet has value...
{
currQty = 0;
}
currQty += qty;
//show data...
datagridviews.Rows[i].Cells["price"].Value = cv.toAccountingCurrency_en(Double.Parse(odr["item_price"].ToString()));
MessageBoxes.Show(i.ToString());
MessageBoxes.Show(datagridviews.Rows[i].Cells["price"].Value.ToString()); // in here there is two price that looped but won't showed in datagridviews
help me out :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…