473,756 Members | 6,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help please on GridView commands + AutoEventWireUp , firing twice etc...

hi,
i'm new to .net 2.0, and am just starting to get to grips with the
gridview.
my page has autoEventWireUp set to true, which i gather is supposed to
figure out which handlers to invoke when appropriate based on your
method names .
the GridView has OnRowCommand="G ridView1_RowCom mand" in the aspx.

my problem is that the RowCommand event is firing twice (95% of the
time) on the page. the other 5% it only fires once. there's no
consistency at all.

in .net 1.1, i would have understood that the code-behind was wiring up
the event, and the aspx was doing the same thing, so this would result
in the event being raised twice. however, in .net 2, i can't find any
code-behind that would be doing this (even looked in temp.asp.net
files).

if i set autoEventWireUp =true, with the OnRowCommand declared in the
GridView aspx, Page_Load fires twice, so does GridView1_RowCo mmand.

if i set AutoEventWireup =false, PageLoad doesn't fire (as is expected)
and GridView1_RowCo mmand only fires once. but occassionally it fires
twice. this is painful! somebody please put me out of my misery :-)

here is my code:
******** ASPX *********
<%@ Page Language="C#" AutoEventWireup ="false"
CodeFile="TestG ridView.aspx.cs " Inherits="Admin _TestGridView" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False" DataKeyNames="P ageID"
DataSourceID="d sPages"
OnRowCommand="G ridView1_RowCom mand">
<Columns>
<asp:BoundFie ld DataField="Titl eForEdit"
HeaderText="Tit le" />
<asp:ButtonFiel d ButtonType="Ima ge"
CommandName="Mo veUp" ImageUrl="../Images/Move_Up.gif"
Text="Move this page up one position" />
<asp:ButtonFiel d ButtonType="Ima ge"
CommandName="Mo veDown" ImageUrl="../Images/Move_Down.gif"
Text="Move this page down one position" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="dsPages" runat="server"
SelectMethod="S elect" TypeName="PageM anager">
</asp:ObjectDataS ource>
</form>
</body>
</html>
********** CODE BEHIND ***********
public partial class Admin_TestGridV iew : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Response.Write( "Page_Load<HR>" );
}

protected void GridView1_RowCo mmand(object sender,
GridViewCommand EventArgs e)
{
Response.Write( "GridView1_RowC ommand<HR>");
}
}

what i did was put break-points in both events, debug, and keep
clicking the up/down buttons until you see the event hit twice for one
click.

thank you
tim

Dec 16 '05
28 10273
up to attention...

Ema

*** Sent via Developersdex http://www.developersdex.com ***
Feb 8 '06 #21
noone answer to this threaD?

Ema

*** Sent via Developersdex http://www.developersdex.com ***
Feb 15 '06 #22
i've reposted the problem due to lack of response on this thread. i
am awaiting a reply from an MS guy. the new thread is at
http://groups.google.com/group/micro...2e4efa2d10e573

Feb 15 '06 #23
Does anyone have an update on this issue? I'm running into the same
thing. Random multiple POSTs causing duplicate charges/credits for
clients. Subsequent POSTs are sent when the first POST receives a 200 0
64 response. Users swear they did not click the Submit button twice.

*** Sent via Developersdex http://www.developersdex.com ***
Feb 23 '06 #24
This bug has been forwarded to Microsoft.
This is the answer from Microsoft Bug adn reported issues:

Thanks for reporting the issue. This is a known issue and we are
investigating fixing this in the next service pack. For the time being
you could use the following work around. One obvious workaround is to
change the button type to a regular button or a link button. If you need
an ImageButton, then you can put an ImageButton in a TemplateField. You
may need to handle the Command event on the ImageButton and call
DeleteRow, passing the RowIndex as the CommandArgument , like this:

<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateFi eld>
<ItemTemplate >
<asp:ImageButto n runat=server id="ImageButton 1" CommandName="De lete"
ImageUrl="..." CommandArgument ='<%# DataBinder.Eval (Container,
"RowIndex") %>' OnCommand="Imag eButton1_Comman d" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>

protected void ImageButton1_Co mmand(object sender, CommandEventArg s e) {
GridView1.Delet eRow(Int32.Pars e(e.CommandArgu ment.ToString() ));
}

Thanks,
The Web Platform and Tools Team
You can find discussion in the site in the previous post or to
http://forum.aspitalia.com/forum/pos...agebutton.aspx
Ema

*** Sent via Developersdex http://www.developersdex.com ***
Feb 24 '06 #25
Arni Bjorn
1 New Member
I ran into the exact same problem, and for some reason, setting the CausesValidatio n="True" to the buttonfield (which b.t.w. is ButtonType="Ima ge") solved it.


hi Steven,
thanks for continuing to look into it. i have just tried it on my
production server, windows 2003 enterrprise, asp.net 2. and i get the
same behaviour, double events for postback.
i found the system log to be a reliable way to record the behaviour of
each event execution. this rules out any debugger anomalies etc.

the output from the IIS log shows the double requests. the log
activity consists of one access to the page, followed by a click on the
move-down button, which as you can see triggers two POST events at the
same time, both with IIS status 200.

#Fields: date time cs-method cs-uri-stem cs-uri-query s-port
cs-username c-ip cs-version cs(User-Agent) sc-status sc-substatus
sc-win32-status sc-bytes
2005-12-21 14:58:57 GET /EventWireupPage .aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+SV 1;+.NET+CLR+1.1 .4322;+.NET+CLR +2.0.50727)
200 0 0 35998
2005-12-21 14:58:57 GET /MoveDown.gif - 8090 - xx.yyy.zzz.zzz HTTP/1.1
Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+SV 1;+.NET+CLR+1.1 .4322;+.NET+CLR +2.0.50727)
404 0 2 1795
2005-12-21 14:59:00 POST /EventWireupPage .aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+SV 1;+.NET+CLR+1.1 .4322;+.NET+CLR +2.0.50727)
200 0 64 0
2005-12-21 14:59:00 POST /EventWireupPage .aspx - 8090 - xx.yyy.zzz.zzz
HTTP/1.1
Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+SV 1;+.NET+CLR+1.1 .4322;+.NET+CLR +2.0.50727)
200 0 0 39927
2005-12-21 14:59:00 GET /MoveDown.gif - 8090 - xx.yyy.zzz.zzz HTTP/1.1
Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+SV 1;+.NET+CLR+1.1 .4322;+.NET+CLR +2.0.50727)
404 0 2 1795

my updated code is below, i didn't make any other changes:
public partial class EventWireupPage : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
System.Diagnost ics.EventLog.Wr iteEntry("ASPNE T", "Page_Load" );
}

protected void GridView1_RowCo mmand(object sender,
GridViewCommand EventArgs e)
{
System.Diagnost ics.EventLog.Wr iteEntry("ASPNE T",
"GridView1_RowC ommand");
}
}

by the way, the only way i noticed it was because of a swap routine
with the move up/down buttons, which obviously when you execute the
same swap twice, it does not change the ordering of the items. if you
use tracing it only shows the trace for one of the postbacks, and
similarly response.Write does not help, so the event log is a sure way
to track it. the event log shows an event for Page_Load corresponding
to the first page access, then there are 2 Page_Load events and 2
RowCommand events, corresponding to the postback(s).

i'm grateful for any more clues you may have to try and get to the
bottom of this.
thanks
tim
Mar 23 '06 #26

Another request for microsoft to provide an official reply. I can verify
the exact behavior describe and add the following. This occurs only in
IE (v. 6 and v. 7). Additionally it occurs on both IIS5 and IIS6, as
well as the local Cassini server.
*** Sent via Developersdex http://www.developersdex.com ***
Feb 6 '07 #27
Hello JHirsch,

Is the Gridview command issue you mentioned here means the double postback
behavior of ImageButton in GridView command field? So far, there is only an
existing issue of this. You can have a look at the following newsgroup
thread to see whether the problem you met is exact the one there:

http://groups.google.com/group/micro...rk.aspnet.webc
ontrols/browse_thread/thread/a9a1bd53c27bd8b 0/82c51830597e5fc 8

Also, for this issue, there is already a public bug entry on the product
feedback center(also recorded in internal bug database):

http://connect.microsoft.com/VisualS...k.aspx?Feedbac
kid=105123

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 7 '07 #28
Hello JHirsch,

Is the bug entry I posted in last message the one meet your scenario?
Please feel free to let me know if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 9 '07 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4905
by: Peter Row | last post by:
Hi, I have created a user control consisting of a textbox and a separate vertical scroll bar. The textbox is filled with data. However there could be lots of data so I only fill the textbox with enough to fill the space visible without scrolling. Having set the min and max values of my separate vertical scrollbar I use that to scroll the data. So for example the textbox could be displaying 50 lines of data but in actual fact there is...
1
1123
by: thomson | last post by:
Hi All, i have written a Web application program, in the page load i have given Response.write=("true") if in the page attribute, the default is AutoEventWireup="false", when i run the program, it shows true as output, executes once But if i keep AutoEventWireup="true", it gives me the result truetrue, that means it is executing twice, Can any one explain me why is it so
0
2291
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web Setup Project and installed My Web Application on my Localhost and it works perfectly. When I install My Web Application on our “Production Server” it just doesn’t update the records on Edit mode!!!
5
2764
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> I have the gridview inside of a master page- content hierarchy.
6
28163
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the RowDataBound event to set the commandargument of the delete button. The event is being fired and works fine. When I press the delete button, the RowCommand event is not firing! and neither is the RowDeleting (the button's commandName is...
3
11717
by: AG | last post by:
Below is code (slightly modified and converted to VB) that was provided to me in response to another post. I am using it to demonstrate another problem. In order for paging and other features to work properly in a gridview, viewstate must be enabled. So, in order to minimize the size of viewstate for a page, I will sometimes turn off viewstate for each control in template columns. That means that the gridview must be databound on each...
8
18087
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to display data in a "GridView" which is tied to an "ObjectDataSource". In turn, this ObjectDatasource gets it's data from a strongly-typed business object within my code.
2
11037
by: John007 | last post by:
I am using a GridView in ASP.Net 2.0 to Insert, Edit, Update and Delete. I am using ItemTemplate and EditItemTemplate and the buttons are LinkButtons. I am inserting a new row from the footer. The RowCommand event is firing twice when I hit the Edit, Update, Delete and Insert buttons. The AutoEventWireup is set to false. What am I missing? Thanks.
5
1934
by: Josephine | last post by:
HI experts, I am new in asp.net. I used Visual Studion 2005 and MS Access 2003 to build aspx files. I used the VS 2005 "DetailView" and "GridView" that has INSERT, EDIT, DELETE function. It is working on my local drive but when i posted it to my web server and I got this error. Can anyone help/assist me? Billion thanks. -----------------------file script---------------------------- <%@ Page Language="VB" AutoEventWireup="false"...
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.