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

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
博客园 - 【当耐特】
H
Help Net Security
腾讯CDC
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
Y
Y Combinator Blog
C
Check Point Blog
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - kingboy

miniSipServer简单而不简单,轻松落地,实现电脑对固话、手机通讯 sql 去重 C# 获取客户端信息 /asp.net/WebService/WebForm C#防止WebBrowser在新窗口中打开链接页面 常用sql语句 sql 复制表 获得 DataSet中的记录总数 MySQL安装的图解 sql 按日期查询 C#中的日期函数使用大全 火车座位分布图 javascript页面跳转常用代码 首页头部下拉广告设计(javascript) GridView 自定义分页 GridView日期格式模版列使用方法 (转) 非常酷的三级下拉菜单!!(javascript) JavaScript 强行弹出窗口 与 无提示关闭页面 sql事务处理(转) o(∩_∩)o...哈哈 在博客园安家了!!
GridView加ObjectDataSource做删除事件(ObjectDataSourceSta...
kingboy · 2008-01-11 · via 博客园 - kingboy

<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);
        }

    
    }