hi guys.
l'm try to popupate some data from database but always fail. I want if the btnAddCariAnggota click will show just nama_anggota not show all row in database.
this is the tbl_anggota
CREATE TABLE [dbo].[tbl_anggota](
[id_anggota] [varchar](50) NOT NULL,
[nama_anggota] [varchar](50) NULL,
[alamat] [varchar](350) NULL,
[no_telpon] [varchar](50) NULL,
[saldo] [bigint] NULL,
CONSTRAINT [PK_tbl_anggota] PRIMARY KEY CLUSTERED
(
[id_anggota] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
this is .aspx
<div class="col-md-6">
<div class="form-group">
<label for="id_anggota">
ID Anggota</label>
<div class="input-group">
<asp:TextBox ID="txtid_anggota" runat="server" CssClass="form-control" placeholder="Enter ID Anggota"></asp:TextBox>
<div class="input-group-append">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnAddCariAnggota" CssClass="btn btn-warning" runat="server" Text="Cari Data Anggota" OnClick="btnAddCariAnggota_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="nama_anggota">
Nama Anggota</label>
<asp:TextBox ID="txtnama_anggota" runat="server" CssClass="form-control" placeholder="Enter Nama Anggota" ReadOnly="true"></asp:TextBox>
</div>
</div>
this code behind
protected void btnCariAnggota_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(koneksi))
{
using (SqlCommand sqlcmd = new SqlCommand("Select * from tbl_anggota where id_anggota='" + txtid_anggota.Text.Trim() + "'",con))
{
con.Open();
sqlcmd.Connection = con;
using (SqlDataReader rdr = sqlcmd.ExecuteReader())
{
while (rdr.Read())
{
txtnama_anggota.Text = rdr["nama_anggota"].ToString();
}
}
con.Close();
}
}
}
any help could be appriciate.