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
 
Ad

Advertisements


Top