This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have two entitites: SymptomGroup and Symptom with a many-to-many association between them implemented via a "through association" on an entity name SGS. I have a repeater binding to SymptomGroup, and within that repeater there's a bulleted list binding to the 'Symptoms' with syntax like so: <asp:BulletedList ID="symptoms" runat="server" DataSource='<%# ((SymptomGroup)Container.DataItem).Symptoms %>'/> This works fine and gives me an output like so:
<asp:BulletedList ID="symptoms" runat="server" DataSource='<%# ((SymptomGroup)Container.DataItem).Symptoms %>' DataTextField='<%# Symptom.Name %>'/> The error is: CS0120: An object reference is required for the non-static field, method, or property 'AuM.Symptom.Name.get' Seems like the 'through association' is not materializing the 'to-many' association. Is this a possible bug? Please help..! |
|
|
If your data source is a Symptoms collection, shouldn't your DataTextField be Name instead of Symptom.Name? The entities are clearly materialised, because you are successfully calling ToString() on them, and the error message is the one you get from trying to use an instance property as if it were static. |
|
|
I have tried: DataTextField='<%# Name %>' and received an error: CS0103: The name 'Name' does not exist in the current context. So I'm not sure what I'm doing wrong..? |
|
|
This seems like an ASP.NET data binding issue. The through association and entities are clearly being loaded because you can see the results of the ToString() call, so I don't think there's a LightSpeed problem. You may be better off trying StackOverflow or the ASP.NET forums. That said... shouldn't it be DataTextField='Name' rather than DataTextField='<%# Name %>'? Doesn't the latter try to evaluate the Name property against some context (not sure what), then set the DataTextField to whatever the value of Name is? |
|
|
You're right, I should've used DataTextField='Name', don't know why I spent past two hours trying everything but that! Even changed how my many-to-many association was setup. I guess after 12 hours of coding I should call it quits.. Thnx for your help. |
|