Delete button not firing

  • Thread starter Andy Sutorius via DotNetMonster.com
  • Start date
A

Andy Sutorius via 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();
}
}
 
J

Joe Fallon

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top