数据库读取
public void getAdb() { int id = Convert.ToInt32(Session["userid"]); string strsql = "select * from tb_user where id=" + id + ""; SqlConnection conn = BaseClass.DBCon(); conn.Open(); SqlCommand cmd = new SqlCommand(strsql, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); imgUpload.ImageUrl = sdr["touxiang"].ToString(); TextBox7.Text = sdr["age"].ToString(); schoolName.Text = sdr["xuexiao"].ToString(); TextBox8.Text = sdr["name"].ToString(); TextBox9.Text = sdr["addres"].ToString(); sr.Text = sdr["shengri"].ToString(); TextBox1.Text = sdr["nicheng"].ToString(); TextBox2.Text = sdr["shouji"].ToString(); TextBox3.Text = sdr["youxiang"].ToString(); Label2.Text = sdr["nicheng"].ToString(); Label3.Text = sdr["shouji"].ToString(); Label4.Text = sdr["youxiang"].ToString(); //DropDownList1.Text = sdr["shengri"].ToString(); //DropDownList2.Text = sdr["shengriy"].ToString(); //DropDownList3.Text = sdr["shengrir"].ToString(); sdr.Close(); conn.Close(); }