FindControl() Question

  • Thread starter Thread starter DotNet
  • Start date Start date
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.
 
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
 
Back
Top