Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

'object' does not contain a definition for '' and no extension method accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

Posted on 2011-10-28
3
Medium Priority
?
755 Views
Last Modified: 2012-05-12
Hi,

I usually code in vb.net not c# so am having problems with my repeater.

<asp:Repeater ID="rptCostumes" runat="server">
            <ItemTemplate>        
                <tr>
                     <td>                      
                        <asp:CheckBox ID="chkDelete" runat="server" />
                        <img src="costumes/<%#DataBinder.Eval(Container.DataItem, "Costume").MainImage.ToString()%>" width="50px" alt="" title="" />
                    </td>

But I am getting:

Error      34      'object' does not contain a definition for 'MainImage' and no extension method 'MainImage' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)      

Works fine for me in vb.net.

Any ideas?
0
Comment
Question by:scm0sml
  • 2
3 Comments
 
LVL 12

Expert Comment

by:viralypatel
ID: 37043912
use this

(DataBinder.Eval(Container.DataItem, "Costume")).MainImage.ToString()

Open in new window



put additional brackets around DataBinder.Eval(Container.DataItem, "Costume")
0
 
LVL 12

Assisted Solution

by:viralypatel
viralypatel earned 1000 total points
ID: 37043917
or try casting DataBinder.Eval(Container.DataItem, "Costume") to (Image)



((Image)DataBinder.Eval(Container.DataItem, "Costume")).MainImage.ToString();

Open in new window

0
 
LVL 4

Accepted Solution

by:
erik_nodland earned 1000 total points
ID: 37043921
Hi

I don't know what object contains the MainImage method but you will need to cast it C# edoesn't do latebinding like VB.Net.

IE <img src="costumes/<%#((YourObject)DataBinder.Eval(Container.DataItem, "Costume")).MainImage.ToString()%>" width="50px" alt="" title="" />

thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question