Link Button in Custom DataList Control

G

Guest

Hi All,

I have created a custom DataList web custom control, which populates data
from a dataset.

This dataset is available at runtime and exposed as property by my custom
control.

During preRender event of custom control, i populate Column Headers, Item
Data from the DataSet using CustomTemplate class for my inner DataList
control.

I have created BaseTemplate class, that extends ITemplate interface to
populate these values.

Now in my DataList, i need to display a link per row, that raises an event
based on the row index.

I am creating these links in BaseTemplate, when i create all the item data
rows.

Please suggest me how i can do this, as the links don't fire the associated
eventhandler that ware declared in BaseTemplate class itself.
 
G

Guest

Hi Pavan,

The links would not fire the associated eventhandlers if they were created
after the Page_Load stage of the page life cycle (for a better understanding
of the page life cycle refer to this article on the MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.asp)

To preserve control events created in a later stage of the page life cycle,
recreate those events upon page_load. You can do that by persisting some
indicators (in the ViewState, the Session or cookies) to redo the event
wiring or even recreating your entire custom control. I have here a sample
that demonstrates this concept:
http://www.societopia.net/Samples/DynamicallyCreatedControls.aspx
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top