newbie: two new errors

  • Thread starter Thread starter IndyChris
  • Start date Start date
I

IndyChris

Okay, I'm getting the following errors for the respective code. Can
anyone help me get around them?

Error-
Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.WebControls.PlaceHolder'
Code-
PlaceHolder ExpandedContent = e.Item.Cells[ConfGrid.Columns.Count -
1].FindControl("ExpandedContent");

Error-
Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.WebControls.ImageButton'
Code-
ImageButton btnExpand = e.Item.Cells[0].FindControl("btnExpand");

I've never worked with either of these types so I really have no idea
what I'm doing.

Thanks
 
IndyChris,

FindControl is not going to return the control of the specific type to
you. You have to perform a cast in order to get the specific typed
instance, like so:

PlaceHolder ExpandedContent = (PlaceHolder)
e.Item.Cells[ConfGrid.Columns.Count - 1].FindControl("ExpandedContent");

ImageButton btnExpand = (ImageButton)
e.Item.Cells[0].FindControl("btnExpand");

Hope this helps.
 
Back
Top