Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have one box...there i want to show the cart items i mean number of items the user clicks...so how can i increment the items when each time user clicks on the products
Posted
Comments
Reza Ahmadi 25-Apr-12 8:51am    
You need to attach some of your code here
[no name] 25-Apr-12 10:06am    
Why?
Reza Ahmadi 25-Apr-12 10:19am    
How they've been implemented? how products shown on the form? I mean they are checkboxes/listbox/in a grid? just more info in needed.
[no name] 25-Apr-12 10:38am    
It is irrelevant how the item is is displayed. Incrementing a number doesn't rely on any particular control.
Reza Ahmadi 25-Apr-12 10:45am    
If it was the case it was very simple just plus 1 to a variable. I think everyone knows how to add to a variable!

You didn't specify the environment, Web or Windows. However, in an ASP.NET environment this sort of thing is usually accomplished by using a session variable. In Windows it would simply be a form variable or a field an entity class.
 
Share this answer
 
Hi,

I am giving example for textbox, so use the below code for wat ever control you selected.

C#
protected void Button1_Click(object sender, EventArgs e)
    {
        int i = 0;
        if (TextBox1.Text != string.Empty)
            i = int.Parse(TextBox1.Text);

        TextBox1.Text = Convert.ToString(i + 1);

    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900