Can i have a Button in a Datalist?
The button is for posting a form to the the Database
FOr example:-
<ASPataList id="heading0" RepeatLayout="Flow"
RepeatDirection="Horizontal" runat="server">
<ItemTemplate>
<asp:button id="cmdSubmit1" class="button"
text=<%#DataBinder.Eval(Container.DataItem, "headerDescription") %>
OnClick="formUpdate" runat="server"/>
</itemTemplate>
</asp:datalist>
But its not firing?
Any ideas?
Yes you can use a Button in a DataList and handle events as you've decribed.
I'm not quite sure why your code snippet isn't working (I don't know what
the codebehind looks like). Another idea for handling events on the Button
in the DataList is to handle the DataList's ItemCommand event. With ItemCommand,
the DataListCommandEventArgs tells you which item in the DataList contained
the button.
That code below looks fine except you have the event wired up twice. You
only need one of the Handles keyword in the VB.NET code or the OnItemCommand
in the ASPX code. Having both will cause the event to be fired twice.
As for the reason the event isn't firing, are you databinding upon every
postback in Page_Load? You should only DataBind when IsPostBack = false,
or, IOW, the first access to the page.