﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Welcome to 陈俊峰's ---BeetleHeaded Man Blog !-文章分类-.NET</title><link>http://www.cppblog.com/Jeff-Chen/category/1403.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 25 May 2008 23:26:42 GMT</lastBuildDate><pubDate>Sun, 25 May 2008 23:26:42 GMT</pubDate><ttl>60</ttl><item><title>A Bug of .Net I Experienced ---- GridView RowEdit/RowDelete/RowUpdate... </title><link>http://www.cppblog.com/Jeff-Chen/articles/5384.html</link><dc:creator>Jeff-Chen</dc:creator><author>Jeff-Chen</author><pubDate>Wed, 12 Apr 2006 05:20:00 GMT</pubDate><guid>http://www.cppblog.com/Jeff-Chen/articles/5384.html</guid><wfw:comment>http://www.cppblog.com/Jeff-Chen/comments/5384.html</wfw:comment><comments>http://www.cppblog.com/Jeff-Chen/articles/5384.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Jeff-Chen/comments/commentRss/5384.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Jeff-Chen/services/trackbacks/5384.html</trackback:ping><description><![CDATA[
		<p align="left">
				<font face="Tahoma">
						<font size="2">
								<font style="BACKGROUND-COLOR: #ffffff">
										<font color="#000000">
												<font color="#008000">
														<strong>
																<em>Part 1 :Qusetion Details:(that's not really i wrote,i just quote a same sample as my encountered) <br /></em>
														</strong>
												</font>
												<br />
										</font>
										<font color="#000000" size="1">  </font>
								</font>
						</font>
				</font>
				<font face="Tahoma">
						<font style="BACKGROUND-COLOR: #ffffff">
								<font size="2">
										<font color="#000000">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?<br /><br />Here's the code for RowEditing:<br />&lt;code&gt;<br />Protected Sub gv_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gv.RowEditing<br />        gv.Columns(columnIndex.Delete).Visible = True<br />        gv.Columns(columnIndex.Id).Visible = False<br />        gv.EditIndex = e.NewEditIndex<br />    End Sub<br />&lt;/code&gt;<br /><br />And here's the code for RowDeleting:<br />&lt;code&gt;<br />Protected Sub gv_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles gv.RowDeleting<br />        e.Cancel = True<br />        Dim lblFName As Label<br />        lblFName= CType(gv.Rows(gv.EditIndex).FindControl("lblFName"), Label)<br />        Dim lblLName As Label<br />        lblLName= CType(gv.Rows(gv.EditIndex).FindControl("lblLName"), Label)<br /><br />        myObject.myClass.DeleteTemp(CType(lblBookletNum.Text, Integer), lblCare.Text)<br />        gvTempVisits.EditIndex = -1<br />    End Sub<br />&lt;/code&gt;<br /><br /></font>
										<font color="#000000">
												<strong>
														<em>
																<font color="#008000">Part 2 : A Reply From Someone</font>
														</em>
												</strong>
										</font>
								</font>
						</font>
				</font>
		</p>
		<p>
				<font style="BACKGROUND-COLOR: #ffffff">
						<font color="#000000">
								<font face="Tahoma" size="2">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. </font>
						</font>
				</font>
		</p>
		<p>
				<font style="BACKGROUND-COLOR: #ffffff">
						<font color="#000000">
								<font face="Tahoma" size="2">I mean if your gridview is declared as follows: </font>
						</font>
				</font>
		</p>
		<p>
				<font style="BACKGROUND-COLOR: #ffffff" face="Tahoma" color="#000000" size="2">[...]<br />   &lt;asp:GridView id="gv" runat="Server" OnRowDeleting="gv_RowDeleting" OnRowEditing="gv_RowEditing" </font>
				<font style="BACKGROUND-COLOR: #ffffff" face="Tahoma" color="#000000" size="2">&gt;<br />      [...]<br />   &lt;/asp:GridView&gt;<br />[...]<br /><br />And in your methods to handle the events are as follows:<br /><br />[...]<br />   Protected Sub gv_RowDeleting(............) </font>
				<font style="BACKGROUND-COLOR: #ffffff">
						<font face="Tahoma" color="#000000" size="2">Handles gv.RowDeleting<br />      [...]<br />   End Sub<br />[...]<br /><br />This events will be called twice. </font>
				</font>
				<br />
				<br />
				<font style="BACKGROUND-COLOR: #ffffff">
						<font face="Tahoma" color="#000000" size="2">
								<font color="#008000">
										<strong>
												<em>Part 3: A Great Discussion about it  i found ! <br /></em>
										</strong>
								</font>
								<br />
						</font>
				</font>
				<a href="http://www.issociate.de/board/post/285047/help_please_on_GridView_commands_+_AutoEventWireUp">
						<font style="BACKGROUND-COLOR: #ffffff">
								<font face="Tahoma" color="#000000" size="2">http://www.issociate.de/board/post/285047/help_please_on_GridView_commands_+_AutoEventWireUp </font>
						</font>
				</a>
				<br />
		</p>
<img src ="http://www.cppblog.com/Jeff-Chen/aggbug/5384.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Jeff-Chen/" target="_blank">Jeff-Chen</a> 2006-04-12 13:20 <a href="http://www.cppblog.com/Jeff-Chen/articles/5384.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>