468,532 Members | 1,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

DataList - Events Not Firing

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?
Nov 19 '05 #1
1 1679
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" <Ji*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
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?

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kenneth | last post: by
2 posts views Thread by Jim Heavey | last post: by
10 posts views Thread by Bharat | last post: by
reply views Thread by manu_srinivasa | last post: by
3 posts views Thread by Patrick Olurotimi Ige | last post: by
4 posts views Thread by Patrick.O.Ige | last post: by
1 post views Thread by shantanu_kush | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.