Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

checkbox visible based on multiple rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
duncfair - 09 Apr 2008 19:03 GMT
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.
Ignacio Machin ( .NET/ C# MVP ) - 09 Apr 2008 20:52 GMT
> asp.net 2.0 and language is c#
>
[quoted text clipped - 7 lines]
>
> 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;
duncfair - 09 Apr 2008 22:26 GMT
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.

On Apr 9, 12:52 pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.com> wrote:

> > asp.net 2.0 and language is c#
>
[quoted text clipped - 19 lines]
>
> checkBox1.Vislble = isVisible;
Ignacio Machin ( .NET/ C# MVP ) - 10 Apr 2008 18:35 GMT
> 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
[quoted text clipped - 30 lines]
>
> - Show quoted text -

can you post your code?
maybe you confused "=" with "=="
duncfair - 11 Apr 2008 18:52 GMT
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;
                    }
           }

On Apr 10, 10:35 am, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.com> wrote:

> > 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
[quoted text clipped - 35 lines]
>
> - Show quoted text -

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.