0

In a textbox I have to write a name that is in the database, when clicking the button has to load data in the gridview, then I added the textbox. I have the following query, I have to display the records in a gridview but I mark this error, "The input string is not formatted correctly."

I have parameters in string and an integer

AppData.DataSet1TableAdapters.PS_USR_ConsultaExternaTableAdapter adapter =   new AppData.DataSet1TableAdapters.PS_USR_ConsultaExternaTableAdapter();

adapter.GetData("", "", "", int.Parse(this.TextBox1.Text));
this.gvbuscar.DataSource = adapter.GetData("", "", "", int.Parse(this.TextBox1.Text));
this.gvbuscar.DataBind();
3
  • int.Parse is throwing the FormatException because this.TextBox1.Text cannot be converted to an int. Could happen if the text was empty or invalid like "abc".
    – Igor
    Commented Dec 7, 2016 at 20:00
  • 2
    Possible duplicate of Input string was not in a correct format
    – Igor
    Commented Dec 7, 2016 at 20:01
  • You need to ensure that there is a check to allow only integers in the text box. Commented Dec 7, 2016 at 20:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.