User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,311 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,337 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3332 | Replies: 140
Reply
Join Date: Feb 2008
Location: Va Beach
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is online now Online
Junior Poster

Re: Insert to DB & View Results on Different Page

  #61  
Feb 20th, 2008
It didn't display any number.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Insert to DB & View Results on Different Page

  #62  
Feb 20th, 2008
Do you have autoeventwireup=true on the top of your ASPX page? Otherwise page_load won't fire.
Reply With Quote  
Join Date: Feb 2008
Location: Va Beach
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is online now Online
Junior Poster

Re: Insert to DB & View Results on Different Page

  #63  
Feb 20th, 2008
Aha it was set to false ... and now this:

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 84:
Line 85: If Not cusID Is Nothing And Not conID Is Nothing And Len(cusID) > 1 And Len(conID) > 1 Then
Line 86: DropDownList1.Items.FindByValue(cusID).Selected = True
Line 87: DropDownList1_SelectedIndexChanged(DropDownList1, e)
Line 88:


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 86
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Insert to DB & View Results on Different Page

  #64  
Feb 20th, 2008
Gosh I hate code-behind. lol. Didn't specify the control or find it
Partial Class AddCall
    Inherits System.Web.UI.Page


    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)
        DropDownList2.SelectedIndex = 0
        FirstName.Text = ""
        LastName.Text = ""
    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch ex As System.Data.SqlClient.SqlException
            End Try

        End Using

    End Sub


    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)
        Dim cusID As String = Trim(Request.QueryString("cusID"))
        Dim conID As String = Trim(Request.QueryString("conID"))

        if Not cusID Is Nothing and Not conID Is Nothing and Len(cusID) > 1 and Len(conID) > 1 then
response.write("11111111111111111111111111")
            Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)
            Dim DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)
            DropDownList1.Items.FindByValue(cusID).Selected = True
            DropDownList1_SelectedIndexChanged(DropDownList1, e)

            DropDownList2.Items.FindByValue(conID).Selected = True
            DropDownList2_SelectedIndexChanged(DropDownList2, e)
else
response.write("22222222222222222222222222")
        end if
    End Sub

    Protected Sub DropDownListEquip_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

End Class
Last edited by SheSaidImaPregy : Feb 20th, 2008 at 4:17 pm.
Reply With Quote  
Join Date: Feb 2008
Location: Va Beach
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is online now Online
Junior Poster

Re: Insert to DB & View Results on Different Page

  #65  
Feb 20th, 2008
Voila ...

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 87: Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)
Line 88: Dim DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)
Line 89: DropDownList1.Items.FindByValue(cusID).Selected = True
Line 90: DropDownList1_SelectedIndexChanged(DropDownList1, e)
Line 91:


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 89
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Insert to DB & View Results on Different Page

  #66  
Feb 20th, 2008
Ok I give up on code-behind. Just use this code:
Partial Class AddCall
    Inherits System.Web.UI.Page


    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 DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)
        DropDownList2.SelectedIndex = 0
        FirstName.Text = ""
        LastName.Text = ""
    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch
            End Try

        End Using

    End Sub


    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)
        Dim cusID As String = Trim(Request.QueryString("cusID"))
        Dim conID As String = Trim(Request.QueryString("conID"))

        if Not cusID Is Nothing and Not conID Is Nothing and Len(cusID) > 1 and Len(conID) > 1 then

        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch
            End Try

        End Using

        end if
    End Sub

    Protected Sub DropDownListEquip_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

End Class
Reply With Quote  
Join Date: Feb 2008
Location: Va Beach
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is online now Online
Junior Poster

Re: Insert to DB & View Results on Different Page

  #67  
Feb 20th, 2008
No errors and nothing in the text fields or ddls.
Last edited by foundsheep : Feb 20th, 2008 at 4:53 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Insert to DB & View Results on Different Page

  #68  
Feb 20th, 2008
ok try this, and let me know what number displays:
Partial Class AddCall
    Inherits System.Web.UI.Page


    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 DropDownList2 As DropDownList = TryCast(FormView1.FindControl("DropDownList2"), DropDownList)
        DropDownList2.SelectedIndex = 0
        FirstName.Text = ""
        LastName.Text = ""
    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch
            End Try

        End Using

    End Sub


    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)
        Dim cusID As String = Trim(Request.QueryString("cusID"))
        Dim conID As String = Trim(Request.QueryString("conID"))

        if Not cusID Is Nothing and Not conID Is Nothing and Len(cusID) > 1 and Len(conID) > 1 then

response.write("1111111111111111111111111")
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch
            End Try

        End Using

else
response.write("2222222222222222222222222")
        end if
    End Sub

    Protected Sub DropDownListEquip_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

End Class
Reply With Quote  
Join Date: Feb 2008
Location: Va Beach
Posts: 179
Reputation: foundsheep is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
foundsheep's Avatar
foundsheep foundsheep is online now Online
Junior Poster

Re: Insert to DB & View Results on Different Page

  #69  
Feb 20th, 2008
11111111111111111 displayed at the top of the page above the content
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Insert to DB & View Results on Different Page

  #70  
Feb 20th, 2008
Oh woops, I forgot to change the data LOL.

Here you go:
Partial Class AddCall
    Inherits System.Web.UI.Page


    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)
        DropDownList2.SelectedIndex = 0
        FirstName.Text = ""
        LastName.Text = ""
    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID = " & DropDownList1.SelectedValue
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE cusID = " & DropDownList2.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE cusID = " & DropDownList1.SelectedValue
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()
            Catch
            End Try

        End Using

    End Sub


    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)
        Dim cusID As String = Trim(Request.QueryString("cusID"))
        Dim conID As String = Trim(Request.QueryString("conID"))

        if Not cusID Is Nothing and Not conID Is Nothing and Len(cusID) > 1 and Len(conID) > 1 then

response.write("1111111111111111111111111")
        'labelSelection.Text = DropDownList1.SelectedItem.Text & " " & DropDownList2.SelectedItem.Text

        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 str_sql As String = "SELECT * FROM Customers WHERE cusID=@cusID"
        Using connection As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")

            Dim command As New System.Data.SqlClient.SqlCommand(str_sql, connection)
            command.Parameters.AddWithValue("@cusID", cusID)

            Try
                connection.Open()
                Dim reader As System.Data.SqlClient.SqlDataReader = command.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
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM CONTACTS WHERE conID=@conID"
                command.Parameters.AddWithValue("@conID", conID)
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        FirstName.Text = reader.Item("FirstName").ToString()
                        LastName.Text = reader.Item("LastName").ToString()
                    end while
                End If
                reader.Close()


                str_sql = "SELECT * FROM Zip WHERE conID=@conID"
                command.Parameters.AddWithValue("@conID", conID)
                command = New System.Data.SqlClient.SqlCommand(str_sql, connection)
                reader = command.ExecuteReader()

                If reader.HasRows then
                    while reader.Read()
                        City.Text = reader.Item("City").ToString()
                        State.Text = reader.Item("State").ToString()
                        Zip.Text = reader.Item("Zip").ToString()
                    end while
                End If
                reader.Close()
                connection.Close()

                DropDownList2.Items.FindByValue(conID).Selected = True
            Catch
            End Try

        End Using

else
response.write("2222222222222222222222222")
        end if
    End Sub

    Protected Sub DropDownListEquip_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

End Class
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 11:13 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC