Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > DataList's EditCommand not being raised

Reply
Thread Tools

DataList's EditCommand not being raised

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-04-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
jasonkester
Guest
Posts: n/a
 
      09-05-2005
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/

 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-05-2005
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
(E-Mail Removed)
http://www.nathansokalski.com/

"jasonkester" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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/
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event not being raised (how to get list of delegates) Karch ASP .Net 2 03-02-2007 07:50 PM
How can I avoid a Die being raised, the handling used does not help daniel.crosby@gmx.de Perl Misc 3 11-17-2006 11:53 AM
DataList's EditCommand not being raised Nathan Sokalski ASP .Net Web Controls 2 09-05-2005 05:43 AM
DataList's EditCommand not being raised Nathan Sokalski ASP .Net 2 09-05-2005 05:43 AM
DataList's EditCommand event not being raised Nathan Sokalski ASP .Net Datagrid Control 0 09-05-2005 02:02 AM



Advertisments