Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

97
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda