findcontrol not getting reference to controls in datagrid footer

J

james_crane

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
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top