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.
 

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

Back
Top