
  public partial class edit : System.Web.UI.Page
  {
      protected void Page_Load(object sender, System.EventArgs e)
      {
          if (【Session】["UserName"] != null && Session["UserName"].ToString() != "")
          {
              if (!Page.【IsPostBack】)
              {
                  ShowUserInfo();
              }
          }
          else
          {
              Response.【Redirect】("login.aspx");
          }
  
      }
  
      //显示用户的当前信息
      public void ShowUserInfo()
      {
          string strConn = System.Configuration.ConfigurationManager.【AppSettings】["DSN"];
          SqlConnection conn = new 【SqlConnection】(strConn);
          lblUserName.Text = 【Session】["UserName"].ToString();
          //从数据库读取用户信息
          string sql = "select * from Users where UserName='" + lblUserName.Text + "'";
          【DataTable】 dt = DBHelper.GetTable(sql);
  
          //把用户信息显示在页面上
          txtRealName.Text =dt.Rows[0]["RealName"].ToString();
          lstSex.SelectedValue = dt.Rows[0]["Sex"].ToString();
          lstQuestion.SelectedValue = dt.Rows[0]["Question"].ToString();
          txtAnswer.Text = dt.Rows[0]["Answer"].ToString();
          txtEmail.Text = dt.Rows[0]["Email"].ToString();
       
      }
      //单击提交按钮
      protected void btnSubmit_Click(object sender, System.EventArgs e)
      {
          if (Page.IsValid)
          {
              string strConn = System.Configuration.ConfigurationManager.AppSettings["DSN"];
              SqlConnection conn = new SqlConnection(strConn);
              string name, realName, sex, pwd, question, answer, email;
              //获取用户输入
              name = Session["UserName"].ToString();
              realName = txtRealName.Text.Trim();
              sex = lstSex.【SelectedItem】.Text.Trim();
              question = lstQuestion.SelectedItem.Text;
              answer = txtAnswer.Text.【Trim】();
              email = txtEmail.Text.Trim();
              //构建UPDATE语句	
              string sql = @"【UPDATE】 Users SET RealName=@RealName,Sex=@Sex," +
              "Question=@Question,Answer=@Answer,Email=@Email  WHERE UserName='" + name + "'";
  
              Hashtable ht = new 【Hashtable】();
              ht.【Add】("realname", realName);
              ht.Add("sex",sex);
              ht.Add("question", question);
              ht.Add("answer",answer);
              ht.Add("email",email); 
              DBHelper.【execSql】(sql, ht);
              Response.【Redirect】("Default.aspx");
          }
      }
  
  }

--答案--
   AppSettings   Session   IsPostBack   Hashtable   execSql   Redirect   UPDATE   SelectedItem   SqlConnection   Session   DataTable   Redirect