DataList - Events Not Firing

G

Guest

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?
 
T

Teemu Keiski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top