日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

GridView RowDeleting 动态添加行,删除行记录 不删除数据库中记录

發布時間:2025/3/20 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 GridView RowDeleting 动态添加行,删除行记录 不删除数据库中记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如果只需刪除GridView中的行, 并不刪除數據庫中的記錄

項次工號姓名?
110022936gracy.ma刪除
210017300eric.mak刪除

?protected void Button1_Click(object sender, EventArgs e)
??????? {
??????????? int rowCount = 1;
??????????? DataTable DT = new DataTable();
??????????? DataRow DR;
??????????? DT.Columns.Add("ORDER_NO");
??????????? DT.Columns.Add("EMP_NO");
??????????? DT.Columns.Add("NAME");
??????????? for (int iRow = 0; iRow < GridView1.Rows.Count; iRow++)
??????????? {
???????????????? DR = DT.NewRow();
??????????????? DR[0] = rowCount;
??????????????? DR[1] = GridView1.Rows[iRow].Cells[1].Text.Trim();
??????????????? DR[2] = GridView1.Rows[iRow].Cells[2].Text.Trim();
??????????????? DT.Rows.Add(DR);
??????????????? rowCount++;
??????????? }

???????????? DR = DT.NewRow();
??????????? DR[0] = rowCount;
??????????? DR[1] = this.TextBox1.Text.Trim();
??????????? DR[2] = this.TextBox2.Text.Trim();
??????????? DT.Rows.Add(DR);
??????????? GridView1.DataSource = DT;
??????????? GridView1.DataBind();
??????????? Session["DataTable"] = DT;
??????? }

??????? protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
??????? {
??????????? DataTable DT=(DataTable)? Session["DataTable"];
??????????? DT.Rows.RemoveAt(e.RowIndex);
??????????? GridView1.DataSource = DT;
??????????? GridView1.DataBind();

??????? }

文章來自于http://mgracy.blog.163.com/blog/static/5764989820114811369947/

轉載于:https://www.cnblogs.com/hqhouse/p/4230517.html

總結

以上是生活随笔為你收集整理的GridView RowDeleting 动态添加行,删除行记录 不删除数据库中记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。