T
Tim_Mac
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="GridView1_RowCommand" 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_RowCommand.
if i set AutoEventWireup=false, PageLoad doesn't fire (as is expected)
and GridView1_RowCommand only fires once. but occassionally it fires
twice. this is painful! somebody please put me out of my misery![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
here is my code:
******** ASPX *********
<%@ Page Language="C#" AutoEventWireup="false"
CodeFile="TestGridView.aspx.cs" Inherits="Admin_TestGridView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="PageID"
DataSourceID="dsPages"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="TitleForEdit"
HeaderText="Title" />
<asp:ButtonField ButtonType="Image"
CommandName="MoveUp" ImageUrl="../Images/Move_Up.gif"
Text="Move this page up one position" />
<asp:ButtonField ButtonType="Image"
CommandName="MoveDown" ImageUrl="../Images/Move_Down.gif"
Text="Move this page down one position" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="dsPages" runat="server"
SelectMethod="Select" TypeName="PageManager">
</asp:ObjectDataSource>
</form>
</body>
</html>
********** CODE BEHIND ***********
public partial class Admin_TestGridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load<HR>");
}
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
Response.Write("GridView1_RowCommand<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
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="GridView1_RowCommand" 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_RowCommand.
if i set AutoEventWireup=false, PageLoad doesn't fire (as is expected)
and GridView1_RowCommand only fires once. but occassionally it fires
twice. this is painful! somebody please put me out of my misery
![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
here is my code:
******** ASPX *********
<%@ Page Language="C#" AutoEventWireup="false"
CodeFile="TestGridView.aspx.cs" Inherits="Admin_TestGridView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="PageID"
DataSourceID="dsPages"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:BoundField DataField="TitleForEdit"
HeaderText="Title" />
<asp:ButtonField ButtonType="Image"
CommandName="MoveUp" ImageUrl="../Images/Move_Up.gif"
Text="Move this page up one position" />
<asp:ButtonField ButtonType="Image"
CommandName="MoveDown" ImageUrl="../Images/Move_Down.gif"
Text="Move this page down one position" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="dsPages" runat="server"
SelectMethod="Select" TypeName="PageManager">
</asp:ObjectDataSource>
</form>
</body>
</html>
********** CODE BEHIND ***********
public partial class Admin_TestGridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load<HR>");
}
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
Response.Write("GridView1_RowCommand<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