Child Controls and Event Handlers

S

Stickley

I have a web form containing 2 design time controls, a
datagrid (myDatagrid) and a Table (myTable). At runtime I
bind the Datagrid to a dataset. I also loop through an
additional dataset and add columns to the table, each
column contains a LinkButton. I attach an event handler
do the LinkButtons using the following command.

theLinkButton.Command += new CommandEventHandler
(My_Command);

If I run the page like I've just described everything
works fine. When I click the HyperText of the LinkButton
the DoPostBack command triggers and passes back whatever
it passes back and the My_command function is called.

Here is the problem I'm having: For my DataGrid, I've
attached a function to the OnItemDataBound event which
fires for each row as it is bound to the Dataset. Based
on a specific value in one of the datagrid cells, I
attach myTable to the specific cell using the following
command:

e.Item.Cells[1].Controls.Add(myTable);

Visually this is working, myTable no longer appears on
the main page but is now in the cell I've attached it to.
The problem is the MyCommand event is no longer triggered
when I click on the Hyperlink for the LinkButton. I can
see that there is a difference between the __doPostBack()
javascript function but I do not understand how to
overcome the problem.

Can anyone help me understand what I need to do to get
the Event handler working when the myTable object is
attached as a child object to myDataGrid.

Thanks for your help,
Stickley
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top