Object casting

G

Guest

I'm trying to cast my object in vsnet 2005. Help!

protected void gvEventsEdit_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

GCS.Business.Event.Event mEvent = ((GCS.Business.Event.Event)e.Row.DataItem);
int ownerGuid = mEvent.EventOwnerGuid;

}
}

any ideas?
 
G

Guest

Chris,

I get:

Unable to cast object of type 'GCS.Business.Event.EventInfo' to type
'GCS.Business.Event.Event'.

Ahh. Ye ole debugger comes thru again.
The problem is probably stemming from my end. What I was doing was putting
a collection in a gridview. Then in the rowbound event casting a Event obj
instead of the EventColl obj.

the corrected code looks like this:

GCS.Business.Event.EventInfo mEvent =
((GCS.Business.Event.EventInfo)e.Row.DataItem);
int ownerGuid = mEvent.EventOwnerGuid;

Thanks.
 

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

Similar Threads


Top