G
Guest
I am using a GridView control with a ButtonField and receiving 2 row command
events for each click of the button. Is there a configuration switch that I
can turn that will ensure I only receive one call to my handler? I'm using
the most basic wiring as it comes out of VS 2005.. Thanks in advance for your
help!
ex/
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!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" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1"
runat="server" OnRowCommand="ApprovalGrid_RowCommand"
AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="EventEmployeeId"
HeaderText="Employee" ItemStyle-Width="80" />
<asp:BoundField DataField="EventTypeId" ItemStyle-Width="100"
HeaderText="Type"/>
<asp:ButtonField buttontype="Image"
ImageUrl="images/icon-approve.gif" HeaderText="Approve" Text="Approve this
Event"
CommandName="ApproveEvent" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AttendanceManagement %>"
SelectCommand="SELECT [EventId], [EventStartDate],
[EventEndDate], [EventDescription], [EventTypeId], [EventHours],
[EventEmployeeId], [EventCreatorId], [EventCreationDate],
[EventLastModifierId], [EventLastModifiedDate], [EventApproved],
[EventApproverId], [EventApprovedDate] FROM [Events]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
-------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
protected void ApprovalGrid_RowCommand(object sender,
GridViewCommandEventArgs e)
{
// Get the index of the clicked row
int rowindex = Convert.ToInt32(e.CommandArgument);
switch (e.CommandName)
{
case "ApproveEvent":
break;
case "EditEvent":
break;
}
}
}
events for each click of the button. Is there a configuration switch that I
can turn that will ensure I only receive one call to my handler? I'm using
the most basic wiring as it comes out of VS 2005.. Thanks in advance for your
help!
ex/
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!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" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1"
runat="server" OnRowCommand="ApprovalGrid_RowCommand"
AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="EventEmployeeId"
HeaderText="Employee" ItemStyle-Width="80" />
<asp:BoundField DataField="EventTypeId" ItemStyle-Width="100"
HeaderText="Type"/>
<asp:ButtonField buttontype="Image"
ImageUrl="images/icon-approve.gif" HeaderText="Approve" Text="Approve this
Event"
CommandName="ApproveEvent" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AttendanceManagement %>"
SelectCommand="SELECT [EventId], [EventStartDate],
[EventEndDate], [EventDescription], [EventTypeId], [EventHours],
[EventEmployeeId], [EventCreatorId], [EventCreationDate],
[EventLastModifierId], [EventLastModifiedDate], [EventApproved],
[EventApproverId], [EventApprovedDate] FROM [Events]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
-------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
protected void ApprovalGrid_RowCommand(object sender,
GridViewCommandEventArgs e)
{
// Get the index of the clicked row
int rowindex = Convert.ToInt32(e.CommandArgument);
switch (e.CommandName)
{
case "ApproveEvent":
break;
case "EditEvent":
break;
}
}
}