惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 熵星尘

苦逼的程序员都是这么玩游戏的(微信:天天连萌) 关于ASP.NET动态加载控件的几点实用总结 记录代码运行耗时的写法 关于Linq to DataTable not in的写法 DevExpress AspxGridView数据绑定 发现一个Membership的bug 无法将类型为“Oracle.DataAccess.Types.OracleString”的对象强制转换为类型“System.String”。 asp.net页面中文件下载的2种方式 - 熵星尘 - 博客园 【部分转】innerText 跟 innerHTML区别 asp.net验证组件membership登录失败的问题 母板页中的引用的图片,JS,css等路径问题 - 熵星尘 - 博客园 如何获取GridView的EmptyDataTemplate中的控件 Mutex实现单实例,你真的搞懂了吗?来看看吧。 VS2008 如何在WinForm中显示flash - 熵星尘 - 博客园 【原创】从图像转换到byte[]数组的几种方法 除夕晚的一帖:如何为repeater内部控件设置javascript,如何取得它们的客户端ID。 回发或回调参数无效。 问题的解决和思考 - 熵星尘 - 博客园 【作品发布】正式发布Tuff的神奇小软盘1.2 【作品发布】QQ2008远程自助 1.5.1.1
gridview 的添加删除等技巧 全部按名称取值
熵星尘 · 2009-12-27 · via 博客园 - 熵星尘

情况1:

使用dataSource绑定的时候使用一个页面变量,GridViewFlow_RowDeleting先执行,紧接着SqlDataSourceFlow_Deleting

private int rowIndex;
    protected void GridViewFlow_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        rowIndex = e.RowIndex;
    }
    protected void SqlDataSourceFlow_Deleting(object sender, SqlDataSourceCommandEventArgs e)
    {
        e.Command.Parameters["v_spfabh"].Value = GridViewFlow.DataKeys[rowIndex]["spfabh"].ToString();
        e.Command.Parameters["v_qztz"].Value = GridViewFlow.DataKeys[rowIndex]["qztz"].ToString();
        e.Command.Parameters["v_hztz"].Value = GridViewFlow.DataKeys[rowIndex]["hztz"].ToString();
        e.Command.Parameters["v_gwbh"].Value = GridViewFlow.DataKeys[rowIndex]["gwbh"].ToString();
        e.Command.Parameters["v_gzlx"].Value = GridViewFlow.DataKeys[rowIndex]["gzlx"].ToString();
        e.Command.Parameters["v_czr"].Value = sysUser.Name;
    }

情况2:使用tableAdapter

protected void GridViewApproval_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            DataSetClass.ApprovalStateDataTable dt = new DataSetClass.ApprovalStateDataTable();
            DataSetClassTableAdapters.ApprovalStateTableAdapter ta = new DataSetClassTableAdapters.ApprovalStateTableAdapter();
            ta.P_DELCONTRACTSTATE(GridViewApproval.DataKeys[e.RowIndex]["HTZTZ"].ToString(), sysUser.Name);
            this.ShowStateList();
        }
        catch (Exception ex)
        {
            WebAction.MessageBox(this, "add", ex.Message, null);
        }
    }

需要注意的:如果没使用datasource进行页面的绑定的话,删除或其他操作后,需要主动进行DataBind()的操作,以便删除后能够刷新显示为删除后的列表数据。