findcontrol not getting reference to controls in datagrid footer

Discussion in 'ASP .Net Web Controls' started by james_crane@btinternet.com, Jan 17, 2005.

  1. Guest

    Hi,

    Really stuck here so help would be greatly appreaciated.
    I have a datagrid and am adding a calander control to the footer
    dynamically...

    if(e.Item.ItemType == ListItemType.Footer)
    {
    Calendar cal = new Calendar();
    cal.ID = "calDate";
    cal.Visible = false;
    e.Item.Cells[0].Controls.Add(cal);
    }
    etc

    Later on I require a reference to this calendar and have tried 3
    routes...

    Calendar cal = (Calendar)Page.FindControl("calDate");
    Calendar cal = (Calendar)Datagrid.FindControl("calDate");
    and also looping through the datagrid thus...

    foreach(DataGridItem di in dgProjectHours.Items)
    {
    Calendar cal = (Calendar)
    di.FindControl("calDate");
    }

    Each of these methods return NULL - the loop attempt only every scans
    item/alternatingitem collection so that not a surprise - but if anyone
    can tell me how to get a reference to a control added to a datagrid
    control at runtime I woudl be gratefull.

    Many thanks
     
    , Jan 17, 2005
    #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. Dave

    Datagrid FindControl in Footer

    Dave, Nov 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    3,093
  2. Ruby

    findcontrol in datagrid footer

    Ruby, Jan 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,829
  3. Replies:
    2
    Views:
    3,120
    KevD711
    Apr 26, 2007
  4. Andrew Robinson

    FindControl in GridView Footer

    Andrew Robinson, Apr 24, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    1,025
    Andrew Robinson
    Apr 25, 2007
  5. Henrik
    Replies:
    1
    Views:
    448
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page