免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
GridView更新代碼
protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)//頁面第依次顯示時(shí),執(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();

//這個(gè)是根據(jù)前面的Datekeynames設(shè)置而得到的。
            //如果多個(gè)鍵值,那么用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
();
    }

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
GridView中選中,編輯,取消,刪除操作?
【ASP.NET】GRIDVIEW控件的一般使用技巧
C# SqlServer連接類 操作類 含存儲(chǔ)過程操作
asp.net連接數(shù)據(jù)庫字符串
asp.net中怎樣調(diào)用存儲(chǔ)過程和存儲(chǔ)過程的寫法
[DropDownList控件]兩個(gè)控件,數(shù)據(jù)間的關(guān)聯(lián) .
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服