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

推荐订阅源

月光博客
月光博客
Martin Fowler
Martin Fowler
博客园_首页
量子位
T
Tailwind CSS Blog
博客园 - Franky
G
Google Developers Blog
D
DataBreaches.Net
Vercel News
Vercel News
B
Blog
Recent Announcements
Recent Announcements
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
爱范儿
爱范儿
博客园 - 【当耐特】
The Cloudflare Blog
H
Help Net Security
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
C
Check Point Blog
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - しovのんeТs

推荐一个很好的网盘,可以在不同电脑间同步文件! VS 2005 VS2008 颜色配置文件下载 在CSDN上看到一个贴子,觉得写得很对,放这里,常看看! ASP.NET 2.0中动态添加 GridView 模板列的例子 ASP.NET 2.0中动态添加GridView - しovのんeТs - 博客园 GridView中的鼠标特效 - しovのんeТs - 博客园 找到一个全能的免费空间!支持SQL和.net2.0 黑英语笑话 ASP.NET 页的客户端 实用体系结构:逻辑分层 准备学2.0在网上找了个Vs2005团除版的http下载地址! 太闷了,换个样子! 现在又要开始忙了! 三个月试用期终于过去了!前途迷茫! 唉,好忙啊,总有做不完的事啊! 公司的网站完成,做一次总结 网站项目管理 如何才能成为一名真正的Web程序员 呵呵,随笔说明!
GridView动态绑定数据、编辑、修改、删除及分页功能
しovのんeТs · 2007-01-29 · via 博客园 - しovのんeТs

 protected void Page_Load(object sender, EventArgs e)
    
{
        
if (!Page.IsPostBack)
        
{
            deptDataBind();
        }

     
    }

    
//数据绑定到控件
    protected void deptDataBind() {
        
//这是一个动态绑定到控件的函数
    }

    
//点击编辑进入到编辑状态
    public void dept_Edit(Object sender, GridViewEditEventArgs e)
    
{
        dept.EditIndex 
= (int)e.NewEditIndex;
        deptDataBind();
    }

    
//删除数据控件上一行
    public void dept_Delete(Object sender, GridViewDeleteEventArgs e)
    
{
        Dept _dept 
= new Dept();
        
int Dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
        
if (_dept.Del(Dept_ID) == 1)
        
{
            Response.Write(
"<script>alert('删除成功!');</script>");

        }

        
else
        
{
            Response.Write(
"<script>alert('删除失败!');</script>");

        }
 
        deptDataBind();
    }

    
//取消数据控件上编辑
    public void dept_Cancel(Object sender, GridViewCancelEditEventArgs e) 
    
{
        dept.EditIndex 
= -1;
        deptDataBind();
    }

    
//把数据控件上的数据更新到数据据库中
    public void dept_Update(Object sender, GridViewUpdateEventArgs e)
    
{
        dept.FooterRow.Enabled 
= false;
        Dept _dept 
= new Dept();
        
int dept_ID = Int32.Parse(((Label)dept.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
        
string dept_Name=((TextBox)dept.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
           
// ……进行相关的更新打操作
        deptDataBind();

    }

         
//进行分页显示
    public void dept_PageIndexChanging(object sender, GridViewPageEventArgs e)
    
{
        dept.PageIndex 
= e.NewPageIndex;
        deptDataBind();
    }

posted @ 2007-01-29 05:54  しovのんeТs  阅读(2805)  评论(1)    收藏  举报

刷新页面返回顶部