GridView加ObjectDataSource做删除事件(ObjectDataSourceStatusEventHandler 委托)


< asp:GridView  ID ="GVAllMemo"  runat ="server"  AutoGenerateColumns ="False"  CellPadding ="4"  GridLines ="None"  Width ="80%"  AllowPaging ="True"  AllowSorting ="True"  DataSourceID ="ObjectDataSource1"  ForeColor ="#333333"  Font-Size ="9pt"    DataKeyNames ="ID"   >
                    
< FooterStyle  BackColor ="#5D7B9D"  ForeColor ="White"  Font-Bold ="True"   />
                    
< RowStyle  BackColor ="#F7F6F3"  ForeColor ="#333333"   />
                    
< SelectedRowStyle  BackColor ="#E2DED6"  Font-Bold ="True"  ForeColor ="#333333"   />
                    
< PagerStyle  BackColor ="#284775"  ForeColor ="White"  HorizontalAlign ="Center"   />
                    
< HeaderStyle  BackColor ="#5D7B9D"  Font-Bold ="True"  ForeColor ="White"   />
                    
< Columns >
                        
< asp:BoundField  DataField ="EndDate"  HeaderText ="提醒时间"  DataFormatString ="{0:yyyy年M月dd日}"   HtmlEncode ="False" />
                        
< asp:TemplateField  HeaderText ="具体事务" >
                            
< ItemTemplate >
                                
< href ="MemoShow.aspx?Date=<%# Eval(" EndDate") % > " class="f12_black" >  <% Eval("event" %> </ a >
                            
</ ItemTemplate >
                        
</ asp:TemplateField >
                        
< asp:BoundField  DataField ="StartDate"  HeaderText ="添加时间"  DataFormatString ="{0:yyyy年M月dd日}"  HtmlEncode ="False"   />
                        
< asp:TemplateField  HeaderText ="完成状况" >
                            
< ItemTemplate >
                               
<% # Convert.ToInt32(Eval("Flag")) == 0 ? "<img src='../images/ico_no.gif' alt='未完成'/>" : "<img src='../images/ico_ok.gif' alt='完成'/>" %>
                            
</ ItemTemplate >
                        
</ asp:TemplateField >
                      
< asp:TemplateField  HeaderText ="编辑" >
                        
< ItemTemplate >
                                
< href ="MemoEdit.aspx?ID=<%# Eval(" id") % > " class="f12_black" > 编辑 </ a >
                            
</ ItemTemplate >
                        
</ asp:TemplateField >
                        
< asp:CommandField  ShowDeleteButton ="True"   />
                    
</ Columns >
                    
< EditRowStyle  BackColor ="#999999"   />
                    
< AlternatingRowStyle  BackColor ="White"  ForeColor ="#284775"   />
                    
< PagerSettings  FirstPageText ="首页"  LastPageText ="末页"  NextPageText ="下一页"  PreviousPageText ="上一页"   />
                
</ asp:GridView >
                
< asp:ObjectDataSource  ID ="ObjectDataSource1"  runat ="server"  SelectMethod ="AllMemo"
                    TypeName
="JL.CRM.BLL.BllMemo"  DeleteMethod ="DelMemo"   OnDeleting ="GridView1_RowDeleting" >
                    
< SelectParameters >
                        
< asp:SessionParameter  Name ="KFnum"  SessionField ="KFnum"  Type ="Int32"   />
                    
</ SelectParameters >
                    
< deleteparameters >
                        
< asp:parameter  name ="ID"  type ="Int32"   />
                    
</ deleteparameters >

                
</ asp:ObjectDataSource >

C#代码段
     protected   void  GridView1_RowDeleting( object  source, ObjectDataSourceMethodEventArgs e)
    
{
        BllMemo DelMemo 
= new BllMemo();
        IDictionary paramsFromPage 
= e.InputParameters;

        
if (DelMemo.DelMemo(Int32.Parse(paramsFromPage["ID"].ToString())))
        
{
            JavaScript.Alert(
"删除成功!"this.Page);
            GVAllMemo.DataBind();
        }

        
else
        
{
            JavaScript.Alert(
"删除失败!"this.Page);
        }

    
    }

转载于:https://www.cnblogs.com/kingboy/archive/2008/01/11/1034863.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值