DataList

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>
&nbsp;<%# 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?
 

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,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top