Welcome to 陈俊峰's ---BeetleHeaded Man Blog !

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  58 随笔 :: 32 文章 :: 18 评论 :: 0 Trackbacks
<2025年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

公告

First Step In My Life ! ------ Make Up My Bad English

常用链接

留言簿(21)

随笔分类(57)

随笔档案(58)

文章分类(31)

文章档案(32)

相册

收藏夹(29)

3D Model

ASP.NET

automotive

Blog

Code Share

COM开发

English Study

GIS

Java

Magazines&News

Marketing

Papers

program language

python

Recommendation

Sites

Tool Manual

Tools Donwload

UI 设计(HMI/...)

WEB Service

WEB2.0

汉字处理

惠州生活资讯

排名/流量统计

数据/信息专栏

搜索引擎设计

网页制作

网易专区

休闲娱乐

资讯搜集

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜

Part 1 :Qusetion Details:(that's not really i wrote,i just quote a same sample as my encountered) 

 
have a gridview and the GridView_RowEditing event is firing twice when I click the edit button and the GridView_RowDeleting event is firing twice on a single delete.  I don't think there's anything that I'm doing in my code that would cause this, but I'm including the code for the two events.  Has anyone encountered this problem?

Here's the code for RowEditing:
<code>
Protected Sub gv_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gv.RowEditing
        gv.Columns(columnIndex.Delete).Visible = True
        gv.Columns(columnIndex.Id).Visible = False
        gv.EditIndex = e.NewEditIndex
    End Sub
</code>

And here's the code for RowDeleting:
<code>
Protected Sub gv_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gv.RowDeleting
        e.Cancel = True
        Dim lblFName As Label
        lblFName= CType(gv.Rows(gv.EditIndex).FindControl("lblFName"), Label)
        Dim lblLName As Label
        lblLName= CType(gv.Rows(gv.EditIndex).FindControl("lblLName"), Label)

        myObject.myClass.DeleteTemp(CType(lblBookletNum.Text, Integer), lblCare.Text)
        gvTempVisits.EditIndex = -1
    End Sub
</code>

Part 2 : A Reply From Someone

verify if in the declarative code of your GridView control are set the OnRowDeleting and OnRowEditing attributes. If so, remove either this attributes or the Handles clauses of your handler events.

I mean if your gridview is declared as follows:

[...]
   <asp:GridView id="gv" runat="Server" OnRowDeleting="gv_RowDeleting" OnRowEditing="gv_RowEditing"
>
      [...]
   </asp:GridView>
[...]

And in your methods to handle the events are as follows:

[...]
   Protected Sub gv_RowDeleting(............)
Handles gv.RowDeleting
      [...]
   End Sub
[...]

This events will be called twice.


Part 3: A Great Discussion about it  i found !

http://www.issociate.de/board/post/285047/help_please_on_GridView_commands_+_AutoEventWireUp

posted on 2006-04-12 13:20 Jeff-Chen 阅读(565) 评论(0)  编辑 收藏 引用 所属分类: .NET

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理