這裏是我的代碼,但是當我用real ID
它運作良好替代dropdownlist.selectedvalue
,所以當我從下拉列表中選擇另一個ID,我需要這樣的變化:根據下拉列表選擇從以文本檢索數據
protected void Page_Load(object sender, EventArgs e)
{
SqlCommand com = new SqlCommand("select * from UsersTable where UserName='" + DropDownListUsers.SelectedValue + "'", conn);
try
{
conn.Open();
using (SqlDataReader red = com.ExecuteReader())
{
while (red.Read())
{
TextBoxpass.Text = (red["password"].ToString());
TextBoxFname.Text = (red["Fname"].ToString());
TextBoxLname.Text = (red["Lname"].ToString());
TextBoxAddress.Text = (red["Address"].ToString());
TextBoxPhone.Text = (red["PhoneNo"].ToString());
TextBoxEmail.Text = (red["Email"].ToString());
TextBoxpass.Text = (red["password"].ToString());
}
}
}
finally
{
conn.Close();
}
}
感謝,它運作良好的代碼之前的所有值< 3 –