It was SelectedValue. Now it is breaking on the button1 again.

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30260: 'Button1_Click' is already declared as 'Protected WithEvents Button1_Click As System.Web.UI.WebControls.Button' in this class.

Source Error:

Line 198:
Line 199:
Line 200: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 201:
Line 202: Dim disID As String


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 200

At least you have an idea of what code it takes to accomplish the task. I'm a designer turned programmer, so my coding is weeeeeeeeeeeeeeeak.

Ok, do this. I hate code-behind..

In your aspx file, add the attribute to Button1:
OnClick="Button1_Click"

Then on your code-behind, remove the last bit of the sub and make it public:
Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Now what this does is makes it so that Button1_Click can be called from anything, anywhere, and now that Button1 has the onclick attribute, it will call it.

Before it was set so ONLY button1 can trigger it.

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC31143: Method 'Protected WithEvents Button1_Click As System.Web.UI.WebControls.Button' does not have a signature compatible with delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.

Source Error:

Line 290: <tr>
Line 291: <td class="style7" colspan="8" valign="top">
Line 292: <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
Line 293: &nbsp;<asp:Button ID="Button2" runat="server" Text="Reset" />
Line 294: </td>


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx Line: 292

Oh woops, remove the top Protected WithEvents Button1.

Ok, now the contact ddl is not populating when you select the company.

post me your code again.

It should be populating, which means we gotta debug. It's probably not returning any results from the query.

Not populating at all? What does it say there?

It's only populating company.

Partial Class AddCall
    Inherits System.Web.UI.Page

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader
    Dim reader2 As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

        If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                Try
                    cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)

                    conn.Open()
                    reader = cmd.ExecuteReader()

                    If reader.HasRows Then
                        DropDownList2.DataSource = reader
                        DropDownList2.DataTextField = "ContactName"
                        DropDownList2.DataValueField = "cusID"
                        DropDownList2.DataBind()
                        DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                        DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                    Else
                        DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
                    End If

                    reader.Close()

                    cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)
                    cmd.Parameters.AddWithValue("@ContactID", conID)
                    reader2 = cmd.ExecuteReader()

                    If reader.HasRows Then
                        While reader.Read()
                            Company.Text = reader.Item("Company").ToString
                            Address1.Text = reader.Item("Address1").ToString
                            Address2.Text = reader.Item("Address2").ToString
                            Phone.Text = reader.Item("Phone").ToString
                            FirstName.Text = reader.Item("FirstName").ToString()
                            LastName.Text = reader.Item("LastName").ToString()
                            City.Text = reader.Item("City").ToString()
                            State.Text = reader.Item("State").ToString()
                            Zip.Text = reader.Item("Zip").ToString()
                        End While
                    End If

                    reader.Close()
                    conn.Close()
                Catch
                End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)

            Try
                conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList1.DataSource = reader
                    DropDownList1.DataTextField = "Company"
                    DropDownList1.DataValueField = "cusID"
                    DropDownList1.DataBind()
                    DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                    If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID))
                Else
                    DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --"))
                End If

                reader.Close()
                conn.Close()
            Catch
            End Try

        End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)
        Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)

        Try
            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList2.DataSource = reader
                DropDownList2.DataTextField = "ContactName"
                DropDownList2.DataValueField = "cusID"
                DropDownList2.DataBind()
                DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
            Else
                DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
            End If

            reader.Close()

            cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID)", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            reader2 = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownListEquip.DataSource = reader
                DropDownListEquip.DataTextField = "CompanyEqpDesc"
                DropDownListEquip.DataValueField = "eqpID"
                DropDownListEquip.DataBind()
                DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
            Else
                DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --"))
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)
        Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)
        cmd.Parameters.AddWithValue("@conID", DropDownList2.SelectedValue)

        Try
            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                While reader.Read()
                    Company.Text = reader.Item("Company").ToString
                    Address1.Text = reader.Item("Address1").ToString
                    Address2.Text = reader.Item("Address2").ToString
                    Phone.Text = reader.Item("Phone").ToString
                    FirstName.Text = reader.Item("FirstName").ToString()
                    LastName.Text = reader.Item("LastName").ToString()
                    City.Text = reader.Item("City").ToString()
                    State.Text = reader.Item("State").ToString()
                    Zip.Text = reader.Item("Zip").ToString()
                End While
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

    End Sub


    Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)
        Dim Notes As TextBox = TryCast(FormView1.FindControl("Notes"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedItem.Value)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedItem.Text)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedItem.Text)

        Try
            conn.Open()
            disID = cmd.ExecuteScalar()

            cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
            cmd.Parameters.AddWithValue("@disID", disID)
            cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

            recs = cmd.ExecuteNonQuery()
            conn.Close()

            If Len(disID) > 0 Then recs += 1

            If recs > 1 Then
                Response.Redirect("Dispatch.aspx")
            Else
                Response.Write("Recs Counted: " & recs & " out of 2.")
            End If
        Catch ex As System.Data.SqlClient.SqlException
            Response.Write(ex)
        End Try

    End Sub

End Class

After Every Catch, add an exception handler to find out what's wrong. Or just comment out EVERY :

Try
Catch
End Try

And you'll find your errors.

Ok, I think I commented everything out that needed to be and this is what I got:

Server Error in '/HRIService' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 111: ' Try
Line 112: cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
Line 113: cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)
Line 114:
Line 115: conn.Open()


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 113

But it's its own function, it should be there as "sender".

Anyway, add this line then. And you might want to do it for DropDownList2 as well, to the next sub, but change it accordingly.

Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)

Did I add it in the right place? I got the same error just two lines further down now.

Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)
                Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)
                Dim DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)

You need to add that in the sub DropDownList1_SelectedIndexChanged.

And also in DropDownList2...
However, you need to change DropDownList1 to 2 in that second sub.

Alrighty, the only thing I changed besides deleting what I just put it, was the

Protected Sub DropDownList2_SelectedIndexChanged

It was referencing ddl1 so I changed it to 2, which could be wrong. Anyway I got the same error. Here is the code as is:

Imports System.Data
Imports System.Data.SqlClient

Partial Class AddCall
    Inherits System.Web.UI.Page

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader
    Dim reader2 As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

        If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                ' Try
                cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                cmd.Parameters.AddWithValue("@cusID", cusID)

                conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList2.DataSource = reader
                    DropDownList2.DataTextField = "ContactName"
                    DropDownList2.DataValueField = "cusID"
                    DropDownList2.DataBind()
                    DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                    DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                Else
                    DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
                End If

                reader.Close()

                cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                cmd.Parameters.AddWithValue("@cusID", cusID)
                cmd.Parameters.AddWithValue("@ContactID", conID)
                reader2 = cmd.ExecuteReader()

                If reader.HasRows Then
                    While reader.Read()
                        Company.Text = reader.Item("Company").ToString
                        Address1.Text = reader.Item("Address1").ToString
                        Address2.Text = reader.Item("Address2").ToString
                        Phone.Text = reader.Item("Phone").ToString
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    End While
                End If

                reader.Close()
                conn.Close()
                '  Catch
                ' End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)

            ' Try
            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList1.DataSource = reader
                DropDownList1.DataTextField = "Company"
                DropDownList1.DataValueField = "cusID"
                DropDownList1.DataBind()
                DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID))
            Else
                DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --"))
            End If

            reader.Close()
            conn.Close()
            ' Catch
            ' End Try

        End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)
        Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)


        ' Try
        cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

        conn.Open()
        reader = cmd.ExecuteReader()

        If reader.HasRows Then
            DropDownList2.DataSource = reader
            DropDownList2.DataTextField = "ContactName"
            DropDownList2.DataValueField = "cusID"
            DropDownList2.DataBind()
            DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
        Else
            DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
        End If

        reader.Close()

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID)", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

        reader2 = cmd.ExecuteReader()

        If reader.HasRows Then
            DropDownListEquip.DataSource = reader
            DropDownListEquip.DataTextField = "CompanyEqpDesc"
            DropDownListEquip.DataValueField = "eqpID"
            DropDownListEquip.DataBind()
            DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
        Else
            DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --"))
        End If

        reader.Close()
        conn.Close()
        ' Catch
        '  End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)
        Dim DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)
        cmd.Parameters.AddWithValue("@conID", DropDownList2.SelectedValue)

        ' Try
        conn.Open()
        reader = cmd.ExecuteReader()

        If reader.HasRows Then
            While reader.Read()
                Company.Text = reader.Item("Company").ToString
                Address1.Text = reader.Item("Address1").ToString
                Address2.Text = reader.Item("Address2").ToString
                Phone.Text = reader.Item("Phone").ToString
                FirstName.Text = reader.Item("FirstName").ToString()
                LastName.Text = reader.Item("LastName").ToString()
                City.Text = reader.Item("City").ToString()
                State.Text = reader.Item("State").ToString()
                Zip.Text = reader.Item("Zip").ToString()
            End While
        End If

        reader.Close()
        conn.Close()
        ' Catch
        'End Try

    End Sub


    Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)
        Dim Notes As TextBox = TryCast(FormView1.FindControl("Notes"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedItem.Value)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedItem.Text)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedItem.Text)

        '   Try
        conn.Open()
        disID = cmd.ExecuteScalar()

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
        cmd.Parameters.AddWithValue("@disID", disID)
        cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

        recs = cmd.ExecuteNonQuery()
        conn.Close()

        If Len(disID) > 0 Then recs += 1

        If recs > 1 Then
            Response.Redirect("Dispatch.aspx")
        Else
            Response.Write("Recs Counted: " & recs & " out of 2.")
        End If
        ' Catch ex As System.Data.SqlClient.SqlException
        ' Response.Write(ex)
        ' End Try

    End Sub

End Class

I don't know. It should have worked. But then again, I can guarantee it would have worked INLINE. You gotta see if there's someone here who does code-behind that can help. Wish I could have.

Ok, thanks for all the help. I'll see what I can find.

Do me a quick favor, I am going to attempt debugging this one more time.

Send over your entire ASPX page coding again, then backup your files (The aspx Page and the CodeBehind.)

I thought I had sent you the aspx code. Apparently, I did not. By the way, I went back to code behind to try to get it working that way. It's not. Some how, some way it will.

You sent me the code on a different post. Not sure why it is bugging up for you, it never has for me.

If you wish, and if you have a copy of your database, email your project to me in a zip file and I will take a look at it:

tirador_matrix@hotmail.com

I'll give that a whirl tomorrow. I don't have access to the files from this computer.

I sent you the site and db, which you may already know when you read this. But just in case you didn't now you know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.