FindControl in Parent Datagrid

H

Harold

I have a datagrid with a template column and template
footer the following code will find the item in the
column but not the footer.

string myVal
foreach (DataGridItem anItem in grdLeads.Items)
{
myVal = ((TextBox)anItem.FindControl("MyVal")).Text;
}

This has no problem with the item collection but the same
run won't access the footer container. Anyone know how to
get at that on withough using the
DataGridCommandEventArgs, that does access it, but
convienient with my class structure
Thanks,

Harold
 
S

Slawek

Hi,

If you want to access footer during the creation of datagrid try to handle
Datagrid_ItemCreated event. Suposing that
dgContentList is a DataGrid you should use in this way:

// page_load ......
{
this.dgContentList.ItemCreated += new
System.Web.UI.WebControls.DataGridItemEventHandler(this.dgContentList_ItemCr
eated);

}



// handler function

private void dgContentList_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if(e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Footer )

{

//do waht you want with footer

}

}


I hope it'll help you.

Regards
Slawek
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top