Child Controls and Event Handlers

Discussion in 'ASP .Net Web Controls' started by Stickley, Nov 26, 2003.

  1. Stickley

    Stickley Guest

    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
     
    Stickley, Nov 26, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Tm92aWNl?=
    Replies:
    1
    Views:
    478
    John Saunders
    Sep 23, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,199
    David Schwartz
    Dec 9, 2003
  3. =?Utf-8?B?TWlrZSBSYW5k?=

    Event handlers and dynamically created controls

    =?Utf-8?B?TWlrZSBSYW5k?=, Jan 25, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    440
    =?Utf-8?B?TWlrZSBSYW5k?=
    Jan 26, 2007
  4. Lucas Tam

    RaisePostBackEvent and Web Controls Event Handlers

    Lucas Tam, Aug 31, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    453
    Teemu Keiski
    Aug 31, 2003
  5. Replies:
    0
    Views:
    219
Loading...

Share This Page