I have a cascading dropdown with several cascades. I want to be able to reset the first choice back to the "Select" in case someone wants to reset the form, but it crashes when I do this. "FormatException was unhandled by user code - Input string was not in a correct format."
Protected Sub ddlBusinessSegment_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlBusinessSegment.SelectedIndexChanged Dim ddlBusinessSegment As DropDownList = DirectCast(sender, DropDownList) If ddlBusinessSegment.SelectedIndex = "4" Then pnlMedicare.Visible = True Else pnlMedicare.Visible = False End If Dim intBO As Integer = Convert.ToInt32(ddlBusinessSegment.SelectedValue.ToString()) FillOrganization(intBO) FillLTPJobFunction(intBO) ddlLineOfBusiness.ClearSelection() ddlJobFunction.ClearSelection() ddlPlatform.ClearSelection() ddlSpecialty.ClearSelection() End Sub
Private Sub FillBusinessSegment() Dim strConn As String = ConfigurationManager.ConnectionStrings("b_SolutionsConnectionString").ConnectionString Dim con As New SqlConnection(strConn) Dim cmd As New SqlCommand() cmd.Connection = con cmd.CommandType = CommandType.Text cmd.CommandText = "SELECT DISTINCT intBO, vcBO FROM vw_JFM" Dim objDs As New DataSet() Dim dAdapter As New SqlDataAdapter() dAdapter.SelectCommand = cmd con.Open() dAdapter.Fill(objDs) con.Close() If objDs.Tables(0).Rows.Count > 0 Then ddlBusinessSegment.DataSource = objDs.Tables(0) ddlBusinessSegment.DataTextField = "vcBO" ddlBusinessSegment.DataValueField = "intBO" ddlBusinessSegment.DataBind() ddlBusinessSegment.Items.Insert(0, "Select") Else lblMsg.Text = "No business segments found" End If End Sub