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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Salman BegRank #284 · 8.8K reputationPosted Jun 10, 2021, 9:31 PM EDT
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
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 11, 2021, 12:14 AM EDT
emma oj176 reputationPosted Jun 13, 2021, 6:38 AM EDT
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.
emma oj176 reputationPosted Jun 13, 2021, 6:58 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 13, 2021, 10:46 AM EDT
Hi,
Please try this one,