Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
Auto populated text box values from data base

I have 4 text boxes. I enter a value in first text box. I want the next 3 text boxes populated values automatically from database based on value entered in the first text box. Can this be done in asp.net?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok, so we have a text box for say a "id' of some sort, like this:

    <div style="text-align:right;width:300px">
        Enter Hotel ID :<asp:TextBox ID="askHotel" runat="server" AutoPostBack="true"></asp:TextBox> <br />
        <br />

        Hotel Name :<asp:TextBox ID="txtHotel" runat="server" Width="180px"></asp:TextBox> <br />
        City  :<asp:TextBox ID="txtCity" runat="server" Width="180px"></asp:TextBox> <br />
        Active :<asp:CheckBox ID="Active" runat="server" ></asp:CheckBox>

    </div>

And our code is:

Protected Sub askHotel_TextChanged(sender As Object, e As EventArgs) Handles askHotel.TextChanged

    Using cmdSQL As New SqlCommand("SELECT * FROM tblHotels WHERE ID = @ID",
                    New SqlConnection(My.Settings.TEST4))

        cmdSQL.Parameters.Add("@ID", SqlDbType.Int).Value = askHotel.Text
        cmdSQL.Connection.Open()
        Dim rst As New DataTable
        rst.Load(cmdSQL.ExecuteReader)

        If rst.Rows.Count > 0 Then
            With rst.Rows(0)
                txtHotel.Text = .Item("HotelName")
                txtCity.Text = .Item("City")
                Active.Checked = .Item("Active")
            End With
        End If
    End Using

End Sub

Output:

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda