473,465 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataList's EditCommand not being raised

I am attempting to raise the EditCommand event of a DataList when a Button
in the ItemTemplate is clicked. Here is the HTML used for the ItemTemplate:

<ItemTemplate>
<asp:Label id=lblEvent1 runat="server" EnableViewState="False"
Width="175px" text='<%# DataBinder.Eval(Container,"DataItem.eventname")
%>'></asp:Label>
<asp:Label id=lblDescription1 runat="server" EnableViewState="False"
Width="500px" text='<%# DataBinder.Eval(Container,"DataItem.description")
%>'></asp:Label>
<asp:Label id=lblDate1 runat="server" EnableViewState="False" Width="100px"
text='<%# DataBinder.Eval(Container,"DataItem.eventdate","{0 :d}")
%>'></asp:Label>
<asp:Label id=lblDetails1 runat="server" EnableViewState="False"
Width="115px" text='<%# DataBinder.Eval(Container,"DataItem.details")
%>'></asp:Label>
<asp:Button id="btnEdit1" runat="server" Width="80px" Font-Bold="True"
CausesValidation="False" Text="Edit Event" CommandName="edit"></asp:Button>
</ItemTemplate>

Here is the event handler used to handle the EditCommand:

Private Sub datEditEvents_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs ) Handles
datEditEvents.EditCommand

Label1.Text = "You clicked index " & CStr(e.Item.ItemIndex)

datEditEvents.EditItemIndex = e.Item.ItemIndex

Dim events As New DataSet

Dim myconnection As New
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))

Dim cmdselect As New OracleCommand("SELECT * FROM eventlist ORDER BY
eventdate", myconnection)

Dim eventsadapter As New OracleDataAdapter(cmdselect)

eventsadapter.SelectCommand = cmdselect

eventsadapter.Fill(events, "eventlist")

datEditEvents.DataSource = events

datEditEvents.DataBind()

End Sub
Notice that I did include the CommandName="edit" in my Button control and
the Handles clause in my event handler. When I click the button, nothing
happens. I tested this using a Label which you see as the first line in my
event handler. What am I forgetting? Is the CommandName attribute
case-sensitive? Am I using the wrong value? Any help would be appreciated.
Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 21 '05 #1
2 1148
You seem to be going nuts with the EnableViewState="False" attributes.
Are you sure you didn't throw one of those onto the DataList or the
Form? That would be sufficient to unhook all your events.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 21 '05 #2
Yes, I'm sure. One thing that I often do in my code to make it faster is
make any Labels that I don't change EnableViewState="False" since the text
is in the aspx file anyway. But here is the code for my opening DataList
tag:

<asp:datalist id="datEditEvents" runat="server" Width="100%"
DataKeyField="eventid">

As you can see, nothing there that I don't need (well, I guess it would
still run without the width, but it might be kind of ugly). Any other ideas?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"jasonkester" <ja*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
You seem to be going nuts with the EnableViewState="False" attributes.
Are you sure you didn't throw one of those onto the DataList or the
Form? That would be sufficient to unhook all your events.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 21 '05 #3

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

Similar topics

3
by: Fabrizio | last post by:
Hi, I'm trying to create a page with a datalist that loads from a template the ItemTemplate, which contains a linkbutton that should have the commandname = "edit" But when I click on the link...
5
by: Ian O'Rourke | last post by:
I'm a bit confused by the datalist. I can put an item in the datalist in editmode by the following dtlBooks.EditItemIndex = e.Item.ItemInde BindBooks( This works great, the problem is when I...
1
by: Etienne Tremblay | last post by:
Hi, I'm currently trying to implement editing in a simple Datalist displaying news on my site. I did everything the walkthrought of microsoft said to do, but it doesn't seem to work. Just for...
2
by: Jim Heavey | last post by:
I have a datalist control and when edit mode, I have three buttons, one for delete, one for cancel and one for Update. My Update button is not causing anything to happen. The other two events...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
1
by: Neil Jarman | last post by:
Hi, I'm new to this today, and I've got some test code (see below.) The data loads fine. I can't understand why any of the events fire. Once the page loads, clicking on thew button from the...
1
by: benoit | last post by:
Hi, I created a Dynamic Datagrid and i added an EditCommandColumn to it. Works fine, but my Editcommand eventhandler seems to have a problem with PostBack This is my code private DataGrid...
3
by: asadikhan | last post by:
Hi, I am trying to use a datalist to edit data in a MySql database as follows. For now I just want to be able to get the changes to be made on the dataset. Here is my code: using System;...
1
by: Arielle | last post by:
Background: I have a generated datalist to display information and I need to add the capability to have a button (Edit button) so that users can change the information. I'm sure once I figure it...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.