Cannot implicitly convert type 'int' to 'string' - NEED HELP

csharp Saudi Arabia
  • 9 years ago

    I don't do web programming, but I think the problem lies in:


    DocumentIDValue.Text = 1;




    DocumentIDValue.Text = "1";


    Hope this helps.

  • 9 years ago

    Text is a property of Textbox which accepts only string type value.

    So, if you want to store a numeric value in Text of a TextBox you should write -

    TextBox.Text = 1.ToString();

    If you want to get Text of a TextBox in a int variable you should write -

    int i = convert.ToInt32(TextBox1.Text);

  • 9 years ago


       if u go that error , so u can now caonvert it into string......

     Ex :

      int i= 65;

      textBox1.Text = i.ToString(); ----->>> menas here u r converting i value 65 into string




  • 9 years ago

    Yes, you are right. I am converting an integer variable to a string variable. Just like 65 to "65". Because TextBox only accepts string type of value as Text.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.”