MVC :: Unable To Increment A Value While Using ViewData?
Apr 7, 2010
The functionality I'm looking for is really simple. I'd like to increment a an integer called
index. Each time I click a button, I post a form to an action method, which increment index and redisplay the view with the new value of the index.
So, I've 2 action methods called Increment (Get and Post versions ):
Increment (GET) action method displays the View, supplying also an initial value of index through the ViewData.
[Code]....
When I click to the button "increment" on the view, I post a form to Increment (POST). The value from the ViewData is sent back to the Controller through an "Hidden field" [Code].... Increment (POST) action method pulls the the value of the index, increments the value, and sends back the new value of index through ViewData when it re-displays the view.[Code]....
Unfortunately, all I can get is ONE increment. in the case above, I get 2. after that, I keep getting 2. If I change the value to 2, I get 3 and nothing else, etc... I suspect that ViewData, once it has gotten a value, keeps it forever.
View 8 Replies
Similar Messages:
Aug 22, 2010
why i could not get 3 at Label2.Text even though i fulfilled the conditions under the if else statement?Is it because counter1 can only be use for one condition
if ((check == true) && (lblQuestion.Text == "1.1"))
{
Button1.Visible = true;
Label1.Text = "You have got it correct, please try the next question.";
Button1.Text = "Next";
[Code]....
View 2 Replies
Jul 4, 2010
Of course, every registration needs a primary key like a registration number. I have a textbox that is visible(for now) and I need to have the value inside it(100001) to increment by 1 for each different registrations. How do I achieve this? I need it in C#.
View 16 Replies
Jul 22, 2010
I have values like 4IT/IT1,i want to update this values like below -
if it is 4IT/IT1 then increment it by 1
so it will be 5IT/IT2 so on...
View 11 Replies
Apr 15, 2010
I have a text box, if i have 1.00.
Then in the textbox1.text it should be 1.01
if i have 1.01 then it should be 1.02
How to increment 10th of a decimals by 1.
View 3 Replies
Apr 29, 2010
i am using one text box in New registration page. when ever user clicks on New registration button, The text box of record number should be auto incremented.
View 12 Replies
Mar 25, 2011
how to increment anchor tag id inside for loop.
View 4 Replies
Mar 23, 2011
I got a table PartsMedia where I can insert all the images related to a product. The table has the columns :
PartsMediaID , auto-increment
PartsNo
MediaLink
MediaDescription
CatalogCode
SortCode
I want to insert a complete row with automatic increment and the PartsNo should be the same as the PartsNo from the PartsMaster table.
The medialink should be the PartsNo + '-2.jpg'
The mediadescription is for example 'image2'
The CatalogCode should be 'catalog'
and the sorting code should be '0'
From The partsMaster table I Just need the PartNo So I can add this to the PartMedia Table. The PartNo is the foreign key in the PartMedia table.
The following I got so far but no luck
insert into dbo.PartsMedia (PartNo,MediaLink,MediaDescription,CatalogCode, SortCode)
values (dbo.PartsMaster.PartNo, PartsMaster.PartNo+'-2.jpg','image2', 'catalog','0')
View 3 Replies
Nov 2, 2010
I use SQL Server and when I create a new table I make a specific field an auto increment
primary key. The problem is some people told me making the field an auto increment for the primary key means when deleting any record (they don't care about the auto increment field number) the field increases so at some point - if the type of my field is integer for example - the range of integer will be consumed totally and i will be in trouble.
So they tell me not to use this feature any more.The best solution is making this through the code by getting the max of my primary key then if the value does not exist the max will be 1 other wise max + 1.Any suggestions about this problem? Can I use the auto increment feature?I want also to know the cases which are not preferable to use auto increment ..and the alternatives...note :: this question is general not specific to any DBMS , i wanna to know is this true also for DBMSs like
View 6 Replies
Jul 8, 2010
I have a simple list of data in my database that I call to my page. I have used the asp.net 'reorder list' ajax control to provide a drag and drop way of managing the sort order of my data. It uses a 'position' column in the database to do this.
How do I go about making sure that when inserting data to this table, the new item gets assigned the correct 'position' value? For example if I have 9 items already in my table, I want this newly inserted list item to get assigned a value of 10 in the position column.
View 5 Replies
Jan 5, 2011
incremnet the variable while page loading each and every time
View 4 Replies
Dec 6, 2010
I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.
The database contains 2 tables :
Question Table :questionID(primary key and identity) , questionInText
Answer table : answerID , answer1,answer2 , questionID
code used to insert to db :
[Code]....
questionID is auto increment.
The question is : How i get questionID after adding to database without using sql statment ?
View 1 Replies
Apr 27, 2016
i want to add an increment id at the place of Lead_ID
<img src="http://track.opicle.com/aff_l?offer_id=2193&adv_sub=Lead_ID" width="1" height="1" />
View 1 Replies
Mar 17, 2014
can i count data entered?
current page only can be proceed to next page only if user entered 2 set of data.
i use count=count + 1
but everytime i enter new data the count back to 0
this is my code
If msg <> "" Then
MessageUser(msg.Substring(0, msg.Length - 1) & "must have value.")
Else
If clsRecruit.NewReference(hd_personid.Value) = True Then
counter = counter + 1
getReference()
txtbox_name.Text = ""
txtbox_residence.Text = ""
txtbox_mobile.Text = ""
txtbox_email.Text = ""
txtbox_job.Text = ""
End If
End If
View 1 Replies
Dec 23, 2013
I have on dropdown list which is bound with database in dropdown list there are months and year i want to do that when i select one data from dropdown list then it should be incremented by 6 and display in text box
For example
I select January 2013 then in text box July 2013 should be displayed...
View 1 Replies
Feb 25, 2016
C# code/form code -
When I submit my form than GenerateNewCID() is not increase continuously it repeat same ID every time as below -
16020001
16020001
16020001 ...
But is want it in the form of below -
16020001
16020002
16020003 ...
//code behind//
private string GenrateNewCId() {
string newCId = string.Empty;
string prefix = DateTime.Now.ToString("yyMM") + "0000";
string selectedIdPrefix = prefix.Substring(0, 4);
int curCId = Convert.ToInt32(prefix.Substring(4, 4));
[Code] ....
View 1 Replies
Apr 27, 2010
<%#ViewData["id"] %>
<h2>MarkerDetail</h2>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$.ajax({
url:"/Marker/MarkerDetailPartial",
data:"",
success:function(result){
$("#ReplyDetails").html(result);
},
error:function(result){
}
});
});
</script>
<div id="ReplyDetails">
</div>
& i want to send Id only By this Ajax
View 1 Replies
Aug 30, 2010
What i want to do is read from a database where the catalog = 12 and then have a button on the page to add a new catalog named 13 so it takes the 12 and adds 1 to it so everytime they click the button they will get a message saying "are you sure you want to create anoter catalog?" and if yes then it executes.
View 5 Replies
Sep 21, 2010
i was given a form in which empid is varchar and i m supposed to auto increment it using a function and calling it ....i have never done this. plz help me out the way .
View 9 Replies
Dec 6, 2010
i'm working on my first project on asp.net using c#.
I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.
The database contains 2 tables :
Question Table :questionID(primary key and identity) , questionInText
Answer table : answerID , answer1,answer2 , questionID
code used to insert to db :
[code]....
View 1 Replies
Jul 26, 2010
how to create a increment using ajax timer? Which mean in ajax timer with a tick int i will increase by 60. E.g. 1st tick from 0 to 60, 2nd tick from 60 to 120, 3rd tick from 120 to 180, continue...
View 9 Replies
Mar 21, 2011
here I'm using a timer control to increment count variable. When I run it on the browser, it shows 1 every time when a timer ticks it's not incrementing can any body tell me why this is happening.Here is the code..
[code]....
View 4 Replies
Apr 28, 2010
i have a question, suppose i have a table 'tblImage' which have 3 rows of data and my auto increment is not +1.
imageId imageName
1 a.gif
2 b.gif
4 c.gif
i want to query '2' using LINQ C# to the table in MS SQL and show the record which i have done easily BUT now i want to get the next auto incremented value to make Next button on the sane web form, which is in this case is '4' and i also want the previous imageId as well.
View 5 Replies
Jan 1, 2011
If its posible I want to create a table with a primary key with auto-increment and a fixed value to differentiate the table from others tables
ex:
table 1 | table 2
ID | ID
----------|-----------
a1 |b1
a2 |b2
a3 |b3
View 6 Replies
Mar 8, 2011
In my loop I am trying to remove items from a list that have a certain name. I can't do this with a for-each, so I tried a regular for-loop. It seems the for loop is not working as expected. It always goes over the limit. I had to put an if-then to break out of the loop (very ugly solution). I'm trying to find the correct way to accomplish this.
[code]...
View 3 Replies