I have a list of products
and I am trying to add them into a datagridview. Each product has a property like id, name, brand, price, stockAmount, isPackaged, and product type properties. What i want is to make invisible the IsPackaged boolean and if that boolean is true change the productType to "packaged" if it is not make it "unpackaged", I dont want in each insertion typing the packageType. However, I get an error like "The name IsPackaged does not exist in the current context"
To hide the isPackage column i found a code that works fine: dataGridView1.Columns["IsPackaged"].Visible = false;
list.Add(new Product()
{
ID = 4,
Name = "Ice Cream",
Brand = "Magnum",
Price = 12,
IsPackaged = true,
ProductType = IsPackaged ? "Packaged" : "Unpackaged" , //Here is the error
StockAmount = 50,
});