how to display database records in textbox on page load
how to display database records in textbox on page load in asp.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Sep 15, 2015, 3:26 AM
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("select * from table where Id='" + value + "'", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Id",value);
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
TextBox1.Text = dr["username"].ToString();
TextBox2.Text = dr["password"].ToString();
TextBox3.Text = dr["fname"].ToString();
TextBox4.Text = dr["gender"].ToString();
}
dr.Close();
con.Close();