DataList bubble event with Buttons

N

Neil

I can't get the event handling to work on Button or ImageButton inside
the header of a DataList. If I change Button to LinkButton it works
fine. Has anyone had this problem? I'm using c# code behind. Here
are the important parts of the code:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="true" Inherits="DataListTest.WebForm1" %>
......

<asp:DataList id="DataList1" style="Z-INDEX: 101; LEFT: 296px;
POSITION: absolute; TOP: 152px"
runat="server" BorderColor="Black" BorderWidth="1px"
OnItemCommand="DataList1_ItemCommand">
<HeaderTemplate>
<asp:Button id="Button1" runat="server" Text="Click Me"
CommandName="Button_Click"></asp:Button>
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Field1") %>
<br>
<asp:LinkButton id="Button1" runat="server" Text="Button"
CommandName="Button_Click"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
.......

public void DataList1_ItemCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
Label1.Text="Button Event Here!";
DataList1.DataSource=DataSetSearch();
DataList1.DataBind();
}

Neil
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top