Link Button in Custom DataList Control

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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

Back
Top