473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Datalist onItemCommand not firing

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>
Nov 18 '05 #1
1 3670
DaWoE wrote:
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.

--
DaWoE
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Barry | last post by:
Hi, I have a Datalist inside the ItemTemplate of another DataList. When I drilldown, I'm not getting any data in either the itemtemplate or headertemplate of the second DataList. I've confirmed...
3
by: Kenneth | last post by:
Hi there, The OnItemCommand in my datalist is acting very weirdly, the first time the page is loaded(or anything on the datalist is clicked for the first time) its firing only once, but after...
3
by: Patrick Olurotimi Ige | last post by:
Can i have a Button in a Datalist? The button is for posting a form to the the Database FOr example:- <ASP:DataList id="heading0" RepeatLayout="Flow" RepeatDirection="Horizontal" ...
1
by: Jim Heavey | last post by:
First time trying to use the Datalist and I can not seem to get the events to fire. I set up my Data List control and I identify the event for the "OnEditCommand". I also set up an...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
1
by: Jules | last post by:
We have a problem setting, actually resetting, the SelectedItemTemplate of a DataList control. Below is the ObjectDataSource and the DataList in .ASPX: <asp:ObjectDataSource ID="mySource"...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
0
by: rn5a | last post by:
The OnItemCommand in a DataList is raised whenever a Button is clicked in the DataList. Assume that a DataList displays 3 columns & the <HeaderTemplatecontains 3 LinkButtons - one for each column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.