473,320 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Delete button not firing

Hi,

I have a delete button in the item template of my datagrid, when I click it
the function for the Insert button is executed instead of the delete button.
When I step through in debug, the doAction function is never entered. Below
is my code. Do you see any errors? Thanks, Andy

<asp:datagrid id="dgdANSI835" runat="server" OnItemCommand="doAction"
ShowFooter="False" Font-Names="verdana" BorderColor="#CCCC99"
BackColor="#CCCC99" Font-Size="8pt" AutoGenerateColumns="False"
DataKeyField="info_id" >
.....
<asp:TemplateColumn>
<HeaderTemplate>
<asp:LinkButton CommandName="Insert" Text="Add" ID="btnAdd" Runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Button CommandName="Delete" Text="Del" ID="btnDelete"
Runat="server"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
.....
public void doAction(object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
dgdANSI835.ShowFooter=true;
}
if (e.CommandName == "Delete")
{
DeleteRow();
}
}
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200506/1
Nov 19 '05 #1
2 3781
My grids are set up the same way.
(But they work. <g>)

The only thing I noticed is the signature of your Sub:

public void doAction(object sender, DataGridCommandEventArgs e)

Mine uses:
public void doAction(object source , DataGridCommandEventArgs e)

Not sure if the difference between source and sender is your problem.
--
Joe Fallon

"Andy Sutorius via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> wrote
in message news:4F***********@DotNetMonster.com...
Hi,

I have a delete button in the item template of my datagrid, when I click
it
the function for the Insert button is executed instead of the delete
button.
When I step through in debug, the doAction function is never entered.
Below
is my code. Do you see any errors? Thanks, Andy

<asp:datagrid id="dgdANSI835" runat="server" OnItemCommand="doAction"
ShowFooter="False" Font-Names="verdana" BorderColor="#CCCC99"
BackColor="#CCCC99" Font-Size="8pt" AutoGenerateColumns="False"
DataKeyField="info_id" >
....
<asp:TemplateColumn>
<HeaderTemplate>
<asp:LinkButton CommandName="Insert" Text="Add" ID="btnAdd" Runat="server"
/>
</HeaderTemplate>
<ItemTemplate>
<asp:Button CommandName="Delete" Text="Del" ID="btnDelete"
Runat="server"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
....
public void doAction(object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
dgdANSI835.ShowFooter=true;
}
if (e.CommandName == "Delete")
{
DeleteRow();
}
}
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200506/1

Nov 19 '05 #2
Hi,

The event is not firing because, I think you are calling the
datagrid.databind method somewhere in Page_Load. You have to check the
IsPostBack property so that the datagrid gets filled only once. This will
fire the appropriate event.

Hope this helps.

"Andy Sutorius via DotNetMonster.com" wrote:
Hi,

I have a delete button in the item template of my datagrid, when I click it
the function for the Insert button is executed instead of the delete button.
When I step through in debug, the doAction function is never entered. Below
is my code. Do you see any errors? Thanks, Andy

<asp:datagrid id="dgdANSI835" runat="server" OnItemCommand="doAction"
ShowFooter="False" Font-Names="verdana" BorderColor="#CCCC99"
BackColor="#CCCC99" Font-Size="8pt" AutoGenerateColumns="False"
DataKeyField="info_id" >
.....
<asp:TemplateColumn>
<HeaderTemplate>
<asp:LinkButton CommandName="Insert" Text="Add" ID="btnAdd" Runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Button CommandName="Delete" Text="Del" ID="btnDelete"
Runat="server"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
.....
public void doAction(object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
dgdANSI835.ShowFooter=true;
}
if (e.CommandName == "Delete")
{
DeleteRow();
}
}
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200506/1

Nov 19 '05 #3

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
6
by: Dotnet Guy | last post by:
I want to add a confirmation dialog box before I delete the records in my form. I have a piece of javascript code in html that checks for confirmation. But the main issue lies in calling this...
2
by: ~~~ .NET Ed ~~~ | last post by:
I have a problem (don't we all?). I have a web form with multiple modules, some of these modules have an ASP.NET (server run) button. OK, now I have UserControlX which has one such button (say...
3
by: Trond | last post by:
I added a delete button to a datagrid. I also added an event: private void dgMessages_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) I added this to event: ...
5
by: csgraham74 | last post by:
Hi guys, I posted regarding this issue the other day but i still dont have an answer to my problem. Basically i have imported asp.net pages from dreamweaver into visual studio. Ive added a...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
3
by: Jay | last post by:
I am on the 2.0 framework and have run the c:\windows\microsoft.net \framework\v1.1.4322\aspnet_regiis.exe -c and had no success. About half of the buttons on my webforms are firing and the other...
0
by: pavankumar106 | last post by:
Hi im stuck in sm simple pb ..im having a datalist in wich im having images and each image have a delete button below it.now wen I press delete button I shud be able to delete that image in dataset...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.