Hello guys
So this is my problem, I have a drop down with values from the database it is also has the option to select none of the values "--Select--"
ddlWinders.Items.Insert(0, new ListItem("--Select--", ""));
and this is the sql parameter definition:
cmd.Parameters.Add("@tubeEndingId", SqlDbType.Int).Value = ddlWinders.SelectedValue
Now when I select the "--Select--" item The obvious thing that happens: System.FormatException: Failed to convert parameter value from a String to a Int32
that is understandable, but I also tried this:
cmd.Parameters.Add("@winderId", SqlDbType.Int).Value = (object)ddlWinders.SelectedValue ?? DBNull.Value;
and the same error pops up which also kind of understandable, So what is the solution.
HELP PLEASE
Thanks