| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2134 人关注过本帖
标题:激发了未处理的事件“RowDeleting
只看楼主 加入收藏
tm_ma
Rank: 1
来 自:中南林
等 级:新手上路
帖 子:147
专家分:0
注 册:2007-3-20
收藏
 问题点数:0 回复次数:0 
激发了未处理的事件“RowDeleting
我的GridView的数据是动态绑定到上面的,在它里面加了一个checkbox,然后单击删除按钮时,删除相应的行(是从数据源删除),前端代码如下:        
<asp:GridView ID="datausers" runat="server">
        <Columns >
        <asp:TemplateField >
        <ItemTemplate >
        <asp:CheckBox ID="cbDel" runat ="server" />
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>
        <asp:CheckBox ID="cbAll" runat="server" AutoPostBack="True" Text="全选" />
        <br />
        <asp:Button ID="Button1" runat="server" Text="删除选中项" />
        <asp:Button ID="Button2" runat="server" Text="取消选中项" />

code-behind如下:
Partial Class usermanager
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            Call binddata()
        End If
    End Sub
    Sub binddata()
        datausers.DataSource = Membership.GetAllUsers
        datausers.DataBind()
    End Sub

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbAll.CheckedChanged
        Dim objItem As GridViewRow
        Dim cb As CheckBox
        For Each objItem In datausers.Rows
            cb = objItem.FindControl("cbDel")
            If cbAll.Checked Then
                cb.Checked = True
            Else
                cb.Checked = False
            End If
        Next
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objitem As GridViewRow
        Dim cb As CheckBox
        For Each objitem In datausers.Rows
            cb = objitem.FindControl("cbDel")
            If cb.Checked Then
                datausers.DeleteRow(objitem.RowIndex)
            End If
        Next
        Call binddata()
    End Sub
End Class

然后出现如题这个问题了!

[[it] 本帖最后由 tm_ma 于 2008-5-10 11:00 编辑 [/it]]
搜索更多相关主题的帖子: quot RowDeleting asp CheckBox GridView 
2008-05-10 10:58
快速回复:激发了未处理的事件“RowDeleting
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027779 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved