Click here to Skip to main content
15,566,394 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how do i convert hidden field datatype from string to int ?

string id = hiddenfield.Value;

I have tried the following,same error - Input string was not in a correct format.

Int32.Parse(hiddenfield.value);

Convert.ToInt32(hiddenfield.value);

Please help

c#


What I have tried:

string id = hiddenfield.Value;

I have tried the following,same error - Input string was not in a correct format.

Int32.Parse(hiddenfield.value);

Convert.ToInt32(hiddenfield.value);

Please help
Posted
Updated 10-Jun-21 20:50pm
Comments
Gerry Schmitz 10-Jun-21 19:40pm    
Aren't you curious about what's in .value?

1 solution

We can't help you: the error is in the data rather than the code (though using TryParse instead of Parse would mean you could handle it better) and we have no access to that.

Basically, whatever your code is putting into the hidden field isn't a number, so when you try to convert it, it complains.
The first thing to do is to find out what exactly it actually is: use the debugger, or write to a log file to find out, and then work back from there to find out why it is that value.

Sorry, but we can't do any of that for you!
 
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