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

csharp Saudi Arabia
  • 6 years ago

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

     

    DocumentIDValue.Text = 1;

     

    Try:

     

    DocumentIDValue.Text = "1";

     

    Hope this helps.

  • 6 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);

  • 6 years ago

    hi,

       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

     

     Regards,

    Swathi.Ch
     

  • 6 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).

Contribute

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.

“Before software should be reusable, it should be usable.” - Ralph Johnson