Dead Buttons

J

Jim Heavey

I have 2 datalist each has 3 buttons in the datalist.

One Datalist, only 2 of the three buttons work in the other one is dead
(no postback, not nothing).

I have another Datalist and on this one, all three buttons are dead (not
postback, not nothing).

To get a button to work on the DataList...here are the rules that I know
of

1. Specify the appropriate "On..." Event attribute when defining the
DataList object. So if you intend to use the "Delete" Command Button,
you must have specified the "OnDeleteCommand" with some method which is
set up to handle the event... "OnDeleteCommand=DoItemDelete".
2. When creating the button in the "EditItemTemplate", you must specify
provide the "CommandName" attribute of the button, and this name must be
"Update" or "Cancel" or "Delete". The command must have the
"Runat='Server' specified as well

SO what am I missing to get these buttons to work?

Here is some code....

<asp:datalist id="dlPPIP" runat="server"
OnItemCommand="PPIP_Process_OnItem"
OnCancelCommand="PPIP_Process_Cancel"
OnDeleteCommand="PPIP_Process_Delete"
OnUpdateCommand="PPIP_Process_Update" DataKeyField="PPIP_ID"
EditItemStyle-BackColor="Yellow" EditItemStyle-ForeColor="black"
OnEditCommand="PPIP_Process_Edit" GridLines="Both">


NONE OF THESE BUTTONS FUNCTION (CAUSE A POSTBACK)
<asp:Button ID="cmdPPIPEditUpdate" CommandName="Update" Text="Update"
Runat="server" CausesValidation="True"></asp:Button>

<asp:Button ID="cmdPPIPEditCancel" CommandName="Cancel" Text="Cancel"
Runat="server" CausesValidation="True"></asp:Button>

<asp:Button ID="cmdPPIPEditDelete" CommandName="Delete" Text="Delete"
Runat="server" BackColor="red" ForeColor="white" Font-Bold="True"
CausesValidation="False"></asp:Button>


If you remove the method for "Update", the error is caught when the form
is attempting to display, so the system is definitely looking for the
form, but it is not wiring the button to the event...what can I
check/change to get this to work?
 
N

Natty Gur

Hi,

Usually this behaviour is due to rebinding the data list on postback.
ensure that you use if(!IsPostBack) to fill datalist just on first call
to page.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
J

Jim Heavey

The problem turn out to be the Validation controls. I did not place an
error message on the controls, and so they were detecting errors at the
client and never doing a post back because the page did not pass local
validation. It really looks like you button is dead when you forget to
provide an error message on validation controls.
 

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,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top