Skip to content
Loading
Populate Some Data into textbox ASP.NET Web Form    
  •   
  • this code bihind
    1. protected void btnCariAnggota_Click(object sender, EventArgs e)  
    2.     {  
    3.         using (SqlConnection con = new SqlConnection(koneksi))  
    4.         {  
    5.             using (SqlCommand sqlcmd = new SqlCommand("Select * from tbl_anggota where id_anggota='" + txtid_anggota.Text.Trim() + "'",con))  
    6.             {  
    7.                 con.Open();  
    8.                 sqlcmd.Connection = con;  
    9.                 using (SqlDataReader rdr = sqlcmd.ExecuteReader())  
    10.                 {  
    11.                     while (rdr.Read())  
    12.                     {  
    13.                         txtnama_anggota.Text = rdr["nama_anggota"].ToString();  
    14.                     }  
    15.                 }  
    16.                 con.Close();  
    17.             }  
    18.         }  
    19.     }  

    3 Replies

    Know the answer? Post it — somebody with the same question will find it here.