checkbox visible based on multiple rows

  • Thread starter Thread starter duncfair
  • Start date Start date
D

duncfair

asp.net 2.0 and language is c#

I need to add a single checkbox on an aspx page based on evaluating
two aspects of the items the customer has placed in the shopping cart.

The price must be $100 or more and the brand must be a specific brand.
There may be multiple items in the cart but there can be only one
checkbox. I wrote some code on the codebehind, but it only evaluates
the last item in the cart. How can I evaluate all o the items?

Thanks in advance for any help.
 
asp.net 2.0 and language is c#

I need to add a single checkbox on an aspx page based on evaluating
two aspects of the items the customer has placed in the shopping cart.

The price must be $100 or more and the brand must be a specific brand.
There may be multiple items in the cart but there can be only one
checkbox.  I wrote some code on the codebehind, but it only evaluates
the last item in the cart.  How can I evaluate all o the items?

Thanks in advance for any help.

What did you write?

ni the code behind you should do something like:
bool isVisible = false;
foreach(Item item in Cart.Items)
if ( item. ..... condition)
{
isVisible = true;
break;
}
checkBox1.Vislble = isVisible;
 
What I have is pretty much what you wrote, but my the visible=true vs
visible=false is only 'looking at' the last item in the cart. Even if
I have an item that meets the criteria, if it's not the last item
added to the cart the checkbox is not visible.
 
What I have is pretty much what you wrote, but my the visible=true vs
visible=false is only 'looking at' the last item in the cart. Even if
I have an item that meets the criteria, if it's not the last item
added to the cart the checkbox is not visible.






- Show quoted text -

can you post your code?
maybe you confused "=" with "=="
 
Dansko_chkbx.Visible = false;
ProductDetailTableAdapter productadp = new
ProductDetailTableAdapter();
DataTable productdatatable =
productadp.GetDanskoProductDetailById(Convert.ToInt32(Orderid.ToString()));
foreach (DataRow ProductDataRow in productdatatable.Rows)
{
DanskoPrice =
Convert.ToDecimal(ProductDataRow["Price"].ToString());
Danskobrandname =
ProductDataRow["BrandName"].ToString();

if ((Danskobrandname.Contains("Dansko")) &&
(DanskoPrice > 100))
{
Dansko_chkbx.Visible = true;
}
else
{
Dansko_chkbx.Visible = false;
}
}
 
Back
Top