1

Say I have the following classes:

public class A
{
    public string x;
}

public class B
{
    public A a;
}

I then bind my repeater to a list of class B's. Is there any way using Eval that I can get class A's x data member?

For example, Eval("A.x"). I know that won't work, but just curious if there was a convention for doing this.

I've looked at this post, but I don't believe it actually answers my question.

2
  • 2
    Have you tried doing this, but using properties rather than public members? Commented Nov 21, 2011 at 16:18
  • Please avoid the asp tag... you know, the one with the big "DO NOT USE" message in the help text when you select it. Commented Nov 21, 2011 at 16:26

2 Answers 2

3

I have not done it using the syntax in the referenced post, but I have done this:

((A)Eval("A")).x

if I have properties.

Sign up to request clarification or add additional context in comments.

Comments

1

You could wrap your Eval in a function that returns the data you're after

<%# PullDataFromObject(Eval("B")) %>


Protected A PullDataFromObject(B myObject)
{
    return B.a;
}

or something like that .. not compile checked etc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.