Datalist onItemCommand not firing

D

DaWoE

Hey,

I don't get my onItemCommand to fire...Can anyone tell me what i'm doing
wrong.

Here is the code :

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load(Sender as object,E as EventArgs)
'Do the binding here

End Sub
Sub DataList1_ItemCommand(Sender as object,E as
DataListCommandEventArgs)

'These are not executed

Response.Write(E.CommandName)
Response.Write(DataList1.DataKeys(E.Item.ItemIndex))
End Sub

</script>
<html>
<head>
<title>Title</title>
</head>
<body>
<form runat="server">

<asp:DataList id="DataList1" runat="server" ShowFooter="False"
ShowHeader="False" RepeatDirection="Horizontal" RepeatLayout="Flow"
DataKeyField="galleryid" OnItemCommand="DataList1_ItemCommand">
<ItemTemplate>
<table height="150" width="300">
<tr>
<td>
<asp:Image id="Image1" runat="server" imageUrl='<%#
Databinder.Eval(Container.DataItem,"galleryID") %>'></asp:Image>
</td>
<td>
<asp:Label id="lblName" runat="server"></asp:Label><%#
Databinder.Eval(Container.DataItem,"name") %>
<br /><br />
<asp:Button id="cmdUpdate" runat="server" CommandName="Update" Text="Add
picture to gallery"></asp:Button>
<asp:Button id="cmdDelete" runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container, "DataItem") %>'
Text="Delete Gallery"></asp:Button>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

</form>
</body>
</html>
 
D

DaWoE

DaWoE said:
Hey,

I don't get my onItemCommand to fire...Can anyone tell me what i'm doing
wrong.

The reason was that the databinding code was executed after postback.
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top