FindControl() Question

D

DotNet

I'd like to capture an attribute of one control from another control called
in the same ASPX page. I can get the ID value, but no other attributes. How
does one do this?

Control MyControl = Parent.FindControl("HeaderTemplate");
if(MyControl != null) {
Response.Write("Value: " + MyControl.ID); //this works fine.
Response.Write("Value: " + MyControl.Section); //this doesn't
work!
Response.Write("Value: " + MyControl.Attributes("Section"));
//this doesn't work either!
}

Thanks.
 
S

Stefano Mostarda

Hi,

You have to cast the HeaderTemplate object.
For instance if HeaderTemplate is a DataGrid, you have to cast it to the
datagrid type and then use it.

((DataGrig)HeaderTemplate).AnyPropertYouWishToUse

Hope this helps.

Stefano Mostarda MCP
Rome Italy
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top