修改页面没有显示SQLDATAREADER的数据
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace gxmath
{
public partial class UserModify : System.Web.UI.Page
{
string connectstring = ConfigurationManager.AppSettings("ConnectionString");
protected void Page_Load(object sender, EventArgs e)
{
if (Session["admin"] == null)
{
Response.Redirect("Contraller.aspx?cname=noadmin");
}
SqlConnection conn = new SqlConnection(connectstring);
conn.Open();
string GX_strsql;
GX_strsql = "select * from users where userid=" + Request["userid"];
SqlCommand comm = new SqlCommand(GX_strsql, conn);
SqlDataReader dr = comm.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
this.tbxLoginName.Text = dr[username].ToString();
this.tbxPassword.Text = dr[password].ToString();
this.tbxName.Text = dr[name].ToString();
if (dr[authorlevel].ToString() == "1")
{
this.ddlUserclass.SelectedValue="超级管理员";
}
else if (dr[authorlevel].ToString() == "2")
{
this.ddlUserclass.SelectedValue = "工作人员";
}
else
{
this.ddlUserclass.SelectedValue = "教师用户";
}
if (dr[sex].ToString() == "男")
{
this.tbxSex.SelectedValued = "男";
}
else
{
this.tbxSex.SelectedValued = "女";
}
this.txbIDNumber.Text = dr[idnumber].ToString();
this.tbxSchool.Text = dr[school].ToString();
this.tbxWorkplace.Text = dr[workplace].ToString();
this.tbxPosition.Text = dr[positions].ToString();
this.tbxPostcode.Text = dr[post].ToString();
this.tbxAddress.Text = dr[address].ToString();
this.tbxTelephone.Text = dr[phonenumber].ToString();
this.tbxEmail.Text = dr[email].ToString();
}
}
conn.Close();
}
}
}