乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      GridView更新代碼

       昵稱14676 2007-12-15
      protected void Page_Load(object sender, EventArgs e)
          {
              if (IsPostBack == false)//頁面第依次顯示時,執(zhí)行數(shù)據(jù)綁定
                  databind();
          }

          protected void databind()
          {
              SqlConnection sqlcon = new SqlConnection("Data Source=KEN;Initial Catalog=aspnettest;Persist Security Info=True;User ID=hyslove;Password=hyslove");
              SqlCommand sqlcom = new SqlCommand("select * from UserTable", sqlcon);
              sqlcon.Open();
              SqlDataAdapter da = new SqlDataAdapter(sqlcom);
              DataSet ds = new DataSet();
              da.Fill(ds, "UserTable");
              GridView1.DataSource = ds.Tables["UserTable"].DefaultView;
              GridView1.DataBind();
              sqlcon.Close();
          }

          protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
          {

          }
          protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
          {
              GridView1.EditIndex = e.NewEditIndex;
              databind();

          }
          protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
          {
              try
              {
                  string username = GridView1.DataKeys[GridView1.EditIndex][0].ToString();

      //這個是根據(jù)前面的Datekeynames設(shè)置而得到的。
                  //如果多個鍵值,那么用GridView1.DataKeys[GridView1.EditIndex].Value三[0];
                  string passwordnew = ((TextBox)(GridView1.Rows[GridView1.EditIndex].Cells[3].Controls[0])).Text.ToString().Trim();
                
                  string sql = "update UserTable set Password='"+passwordnew+
                      "' where Username='" + username + "'";
                  SqlConnection sqlcon = new SqlConnection("Data Source=KEN;Initial Catalog=aspnettest;Persist Security Info=True;User ID=hyslove;Password=hyslove");
                  SqlCommand sqlcom = new SqlCommand(sql, sqlcon);
                  sqlcon.Open();
                  sqlcom.ExecuteNonQuery();
                  sqlcon.Close();
                  GridView1.EditIndex = -1;//返回正常狀態(tài)
                  databind();
              }
              catch (Exception ex)
              {
                  Response.Write(ex.Message);
              }

          }
          protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
          {
              GridView1.EditIndex = -1;
              databind
      ();
          }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約