convert hiddenfield 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
convert hiddenfield 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
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Jun 13, 2021, 2:46 PM
Hi,
Please try this one,
emma ojPosted Jun 13, 2021, 10:58 AM
emma ojPosted Jun 13, 2021, 10:38 AM
I tried this
int id = 0; int.TryParse(hfId.Value, out id);
Session["DatakeyValue"] = id;
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('" + id + "')", true);
The response was 0,,data was not selected into it Label.Text ,because the id of the Grid view row cell is not present in id.
Jignesh KumarPosted Jun 11, 2021, 4:14 AM
Salman BegPosted Jun 11, 2021, 1:31 AM
Hey you can try like this Int32.Parse(hiddenfield.value) Convert.ToInt32(hiddenfield.value) But if hiddenfield value contains int value like 10 Or 20 Or any int value then it will work. Let's say if hiddenfield value contains any string like xyz or abc or any string value then you can't convert that string to int and at that time it will throw Input string was not in a correct format error. So in simple, you can't convert any string value to int but if value contains any int value then you can convert. See this video for more info, https://youtu.be/32Y_mHwD01U
https://youtu.be/PKlH1HCeGVE