PC Review


Reply
Thread Tools Rate Thread

DataList - Events Not Firing

 
 
=?Utf-8?B?SmltIEhlYXZleQ==?=
Guest
Posts: n/a
 
      16th Aug 2005
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 "<ItemTemplate>" in which I place a
ASP:Button control in and I specify the "CommandName" property for this
button to be "edit". I ensure that my control has the Datasource propery set
to my DataTable.
When I press the button in the DataList control, the Form load even fires
and I retrieve my DataTable from my viewState and then re-associated that
datatable to the DataSource of my Datalist control, but the Event never fires.

I can not get the "OnItemCommand" to fire either.

Any ideas as to what I am doing wrong?
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      16th Aug 2005
Hi,

are you setting the data source on every postback? If that's the case,
that's the source of your problems. You should ensure it is set (DataList is
databound) only for initially in Not Page.IsPostBack check in Page_Load.
Later on the rebinding happens in postback events or as is needed, however
you shouldn't bind the dataList in Page_Load on every request as that clears
events to be raised for the control in question.

E.g

Public Sub Page_Load(...) Handles MyBase.Load
If Not Page.IsPostBack Then
'Binding the DataList here
BindDataList()
End If
End Sub

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Jim Heavey" <(E-Mail Removed)> wrote in message
news:515F6C82-EC4D-4F9B-8CAF-(E-Mail Removed)...
> 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 "<ItemTemplate>" in which I place a
> ASP:Button control in and I specify the "CommandName" property for this
> button to be "edit". I ensure that my control has the Datasource propery

set
> to my DataTable.
> When I press the button in the DataList control, the Form load even fires
> and I retrieve my DataTable from my viewState and then re-associated that
> datatable to the DataSource of my Datalist control, but the Event never

fires.
>
> I can not get the "OnItemCommand" to fire either.
>
> Any ideas as to what I am doing wrong?



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
dynamically adding controls with events (but events are not firing) SevDer Microsoft ASP .NET 2 13th Nov 2007 06:33 AM
DataList in a composite control. ItemCommand not firing. shantanu_kush@hotmail.com Microsoft ASP .NET 1 24th Jul 2006 10:58 AM
DataList - Firing an event for a drop down list box in the header =?Utf-8?B?R2FyeQ==?= Microsoft ASP .NET 1 21st Feb 2006 06:32 PM
OnSelectedIndexChanged event not firing on a DropDownList within a DataList Paul L Microsoft ASP .NET 1 6th May 2005 01:12 AM
Datalist onItemCommand not firing DaWoE Microsoft ASP .NET 1 25th Jun 2004 02:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:52 AM.