By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

DataList - Events Not Firing

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.