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

推荐订阅源

N
News and Events Feed by Topic
V
V2EX
博客园 - 【当耐特】
Vercel News
Vercel News
雷峰网
雷峰网
爱范儿
爱范儿
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
NISL@THU
NISL@THU
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
P
Proofpoint News Feed
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
I
InfoQ
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 最新话题
Project Zero
Project Zero
Engineering at Meta
Engineering at Meta
V
Visual Studio Blog
AI
AI
Schneier on Security
Schneier on Security
B
Blog RSS Feed
T
Tor Project blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Cyber Attacks, Cyber Crime and Cyber Security
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
Arctic Wolf
Webroot Blog
Webroot Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main

博客园 - 胡枫

ASP.NET URL Rewrite. URL重写 asp.net 中DataGrid自定义分页(简单,实用,易懂) 实现类似textarea这样可以滚动显示内容的方法 各种浏览器CSS hack方法 HTML+CSS+JS学习笔记 JS学习笔记ZT Asp.net 备份、还原Ms SQLServer及压缩Access数据库 我该怎样卸载IE7? ASP.NET Application,Session,Cookie和ViewState等对象用法和区别 (转) ASP读取显示TXT文件内容 ASP.NET 防注入的两个通用函数 innerText,outerText,innerHTML,outerHTML 如何在TextBox控件中显示系统当前时间?包括:年、月、日、时、分 ASP.NET 防注入的两个通用函数 C# 操作ACCESS数据库 ASP判断是否包含字符串(InStr 函数) asp.net2.0中Repeater的分页使用 ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子! asp.net中没有类似asp中Left()函数怎么办?
一个GridView编辑删除的例子
胡枫 · 2007-11-21 · via 博客园 - 胡枫

<asp:GridView ID="myGvClass" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyNames="id" OnRowCancelingEdit="myGvClass_RowCancelingEdit" OnRowEditing="myGvClass_RowEditing" OnRowUpdating="myGvClass_RowUpdating" OnRowDeleting="myGvClass_RowDeleting" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px">
              
<Columns>
                  
<asp:BoundField DataField="id" HeaderText="序号" ReadOnly="True">
                      
<ItemStyle HorizontalAlign="Center" />
                      
<HeaderStyle HorizontalAlign="Center" Width="10%" /></asp:BoundField>
                  
<asp:BoundField DataField="classname" HeaderText="栏目名称">
                      
<ItemStyle HorizontalAlign="Left" />
                      
<HeaderStyle HorizontalAlign="Left" Width="52%" />
                      
<ControlStyle Width="80%" />
                  
</asp:BoundField>
                  
<asp:BoundField DataField="stime" HeaderText="操作时间" ReadOnly="True">
                      
<ItemStyle HorizontalAlign="Center" />
                      
<HeaderStyle HorizontalAlign="Center" Width="20%" /></asp:BoundField>
                  
<asp:CommandField HeaderText="操作" ShowEditButton="True">
                      
<HeaderStyle HorizontalAlign="Center" Width="12%" />
                      
<ItemStyle HorizontalAlign="Center" /></asp:CommandField>
                  
<asp:TemplateField HeaderText="删除" ShowHeader="False">
                      
<ItemStyle HorizontalAlign="Center" />
                      
<HeaderStyle HorizontalAlign="Center" Width="6%" />
                      
<ItemTemplate>
                          
<asp:LinkButton ID="LinkButton1" OnClientClick="return confirm('您确认删除该记录吗?');" runat="server" CausesValidation="False" CommandName="Delete"
                              Text
="删除"></asp:LinkButton>
                      
</ItemTemplate>
                  
</asp:TemplateField>
              
</Columns>
              
<HeaderStyle BackColor="LightGray" />
              
</asp:GridView>

protected void myGvClass_RowEditing(object sender, GridViewEditEventArgs e)
    
{
        myGvClass.EditIndex 
= e.NewEditIndex;
        
this.myGvClass.EditRowStyle.BackColor = Color.AliceBlue;
        BinData();
    }

    
protected void myGvClass_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    
{
        myGvClass.EditIndex 
= -1;
        BinData();
    }

    
protected void myGvClass_RowUpdating(object sender, GridViewUpdateEventArgs e)
    
{
        
string strID = this.myGvClass.DataKeys[e.RowIndex].Value.ToString();
        
string strClassName = ((TextBox)(myGvClass.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim().ToString();

        WebClass.ArticleList tmp 
= new WebClass.ArticleList();
        tmp.EditClass(strClassName,strID);

        myGvClass.EditIndex 
= -1;
        BinData();
    }

    
protected void myGvClass_RowDeleting(object sender, GridViewDeleteEventArgs e)
    
{
        
string strID = this.myGvClass.DataKeys[e.RowIndex].Value.ToString();

        WebClass.ArticleList tmp 
= new WebClass.ArticleList();
        tmp.DelClass(strID);

        myGvClass.EditIndex 
= -1;
        BinData();
    }