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();
Kritner
  • 13,557
  • 10
  • 46
  • 72
MichaelPth
  • 71
  • 3
  • 9
  • `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 Dec 07 '16 at 20:00
  • 2
    Possible duplicate of [Input string was not in a correct format](http://stackoverflow.com/questions/8321514/input-string-was-not-in-a-correct-format) – Igor Dec 07 '16 at 20:01
  • You need to ensure that there is a check to allow only integers in the text box. – TheFallenOne Dec 07 '16 at 20:04

0 Answers0