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();
}
}
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();
}
}