J
Jim Heavey
Hello, I am trying to figure out why a method for one of my buttons is
running twice.
In defining my DataList, I have the following line in the HTML document
OnItemCommand="ProcessHighlightEditItem"
OnUpdateCommand="ProcessHighlightUpdateCommand"
OnDeleteCommand="ProcessHighlightDeleteCommand"
OnCancelCommand="ProcessHighlightCancelCommand"
My "ItemTemplate" looks like the following:
<ItemTemplate>
<asp:Button Text="Edit" CommandName="Edit" Runat="server"
ID="cmdEditHighlights"></asp:Button>
<asp:Button Text="Delete" CommandName="Delete" Runat="server"
ID="cmdDeleteHighlights"></asp:Button>
<%# DataBinder.Eval(Container.DataItem, "Descrp" ) %>
</ItemTemplate>
In My ItemTemplate, note that I have a "Delete" button. I also Have
another "Delete" Button in the EditItem Template (template not provided)
In my OnItemCommand, I specify the method to run is
"ProcessHighlightEditItem".
The code for this method looks like the following:
public void ProcessHighlightEditItem(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
dlHighlights.EditItemIndex = e.Item.ItemIndex;
dlHighlights.DataSource = _DTHighlights;
dlHighlights.DataBind();
}
else if (e.CommandName == "Delete")
{
ProcessHighlightDeleteCommand(source, e);
}
}
ProcessHighlightEditItem which is associated with the "OnItemCommand" is
being run twice. Any ideas why?
running twice.
In defining my DataList, I have the following line in the HTML document
OnItemCommand="ProcessHighlightEditItem"
OnUpdateCommand="ProcessHighlightUpdateCommand"
OnDeleteCommand="ProcessHighlightDeleteCommand"
OnCancelCommand="ProcessHighlightCancelCommand"
My "ItemTemplate" looks like the following:
<ItemTemplate>
<asp:Button Text="Edit" CommandName="Edit" Runat="server"
ID="cmdEditHighlights"></asp:Button>
<asp:Button Text="Delete" CommandName="Delete" Runat="server"
ID="cmdDeleteHighlights"></asp:Button>
<%# DataBinder.Eval(Container.DataItem, "Descrp" ) %>
</ItemTemplate>
In My ItemTemplate, note that I have a "Delete" button. I also Have
another "Delete" Button in the EditItem Template (template not provided)
In my OnItemCommand, I specify the method to run is
"ProcessHighlightEditItem".
The code for this method looks like the following:
public void ProcessHighlightEditItem(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
dlHighlights.EditItemIndex = e.Item.ItemIndex;
dlHighlights.DataSource = _DTHighlights;
dlHighlights.DataBind();
}
else if (e.CommandName == "Delete")
{
ProcessHighlightDeleteCommand(source, e);
}
}
ProcessHighlightEditItem which is associated with the "OnItemCommand" is
being run twice. Any ideas why?