Reputation: 169 Stalwart
- Active Posts:
- 588 (0.39 per day)
- 03-February 10
- Profile Views:
- Last Active:
- Yesterday, 06:43 AM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 7 Mar 2014Are you trying to add the input from textbox 3 to a listbox when you click button 6? In which case just add the values to the listbox, instead of trying to create an array.
Once again Page Life Cycle plays a big part. When the page posts back to the code behind if you haven't taken steps to save data in either the SessionState or ViewState it can be lost. (Could also be stored into a database or other form of storage, but that is just complicating this issue)
Posted 7 Mar 2014You can use: <asp:Image ></asp:Image>, <img />
I think you need to give us more info on what you are trying to accomplish. Code is helpful in most cases as well.
Posted 7 Mar 2014It appears that the process of calculating with the new values is a bit out of order. Below I simplified the code a bit but I think you might see where you will need to adjust the order of operations.
Starting at line 22 of the posted code:
ItemCount = DG.QTY
NewQty = ItemCount + Order.QTY
NewPrice = DG.QTY * DG.PRICE
DG.TOTAL = NewPrice
DG.QTY = ItemCount
DG.QTY = NewQty
Posted 6 Mar 2014What won't refresh, result? If you have it declared at the class level, which it sounds like, then you are probably setting it in the form load method. If you don't change the value of result at some other point in your code then it can't change.
Have you tried putting a break point on the line 14 of that method and checking the values of result, credit and nocredit through multiple runs?
Maybe we just need to see more of the code? The story seems to be incomplete.
The code you have posted tells this story:
At some point result is set to some value between 0 and 4 (0,1,2,3,4 - that is a total of 5 values).
The combobox is then used to select a value.
If the selected values index is 0,1 or 2 then that selected index number is put into the credit variable.
If the selected values index is 3 or 4 then that selected index number is put into the nocredit variable.
Then a comparison is made between result and credit, if they are the same then we change the value a label value. If they are not the same then we compare the value of result to nocredit and if they are the same then we change the label value. If no values match - then no change to the label.
Let's walk through this.
Form loads - credit = 0, nocredit = 0, result = 0 (I am assuming that these variables are declared as Integer or Int32)
As the form loads result is set to (lets pick) 2.
The user chooses a value from the combobox, lets pick the 4th value in the list - so that means it would have a selected index of 3. So the first part of the code says that we set nocredit = 3 now.
So the second part of the code - does result(2) = credit(0)? no so then we do result(2) = nocredit(3)? no
No change to the label.
Another value is choosen from the combobox - this time it is the 3rd value in the combobox - which is selectedindex 2.
The first part of the code says that we set credit = 2 now.
At this point result = 2, credit = 2, and nocredit = 3.
The second part of the code runs - does result(2) = credit(2)? yes - hey we can change the label to 'Credit'
Posted 6 Mar 2014This is where you have to remember what Scope is and also what the Page Life Cycle is.
You click on your Button6 - the page posts back carrying with it all the values in the server controls. The Page_Load event will run (in this case) and then your Click method will fire. The nums array is instantiated and is filled with TextBox3.Text value 3 times, then the method ends and the nums array goes out of scope.
Check these out they should give you some ideas:
Brief look at ViewState
Understanding ASP.Net ViewState
ASP.Net Session State Overview
or you may just need to look for Hidden fields
- Member Title:
- D.I.C Addict
- Age Unknown
- February 2
- my family, reading, programming,
- Full Name:
- Years Programming:
- Programming Languages:
- VB.NET, C#.NET, ASP.NET, SharePoint 2007 development