I’m trying to get 2 int and 3 strings inserted into the database from a label and 4 tekstboxes.
The Error I’m getting:
The method Insert has some invalid arguments, the argument cannot convert from string to int.
lblHidden.Text and TextBoxDagnummer.Text have strings in them but I need to convert them into integers. Do I convert them before the Insert or in the insert and what is the syntax?
Code behind
protected void Button2_Click(object sender, EventArgs e)
{
Vakinhoudclass.Insert(lblHidden.Text, TextBoxDagnummer.Text, TextBoxHoofdstuk.Text, TextBoxOnderwerp.Text, TextBoxLes.Text);
GridView1.DataBind();
}
You need to parse out the integers from the strings.
Use the
int.Parseorint.TryParseto get integers from the inputs.If the input cannot be parsed,
int.Parsewill throw an exception, whileTryParsewill return aboolindicating whether it was able to parse or not.