2 objects at once ?

J

Jarod

Hey!
How to display 2 object at once using ObjectDataSource? Let's say I have
gridView and I want to display 5 columns from one object and another 5 from
another object. If I were using SqlDataSource I'd just join to tables but
it's not that simple so... is there a way to do it with objects ?
Jarod
 
G

Greg Young

Create a wrapper object

public class Foo {
public int Bar;
}

public class Foo2 {
public int Bar2 {
}

public class BindingClass {
private Foo foo;
private Foo2 foo2;

public int Bar {
get { return foo.Bar; }
set { foo.Bar = value; }
}

public int Bar2 {
get { return foo2.Bar2; }
set { foo2 .Bar2 = value; }
}
public BindingClass(Foo _Foo, Foo2 _Foo2) {
foo = _Foo;
foo2 = _Foo2;
}
}

then use binding class to bind the object.

Cheers,

Greg
 

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

Top