DataBinder in asp.net

333 views Asked by At

i have this: ( useing Repeater but this bit long with all the fields problem is with this one)

<td valign="top">
<%#DataBinder.Eval(Container.DataItem, "Category")%>
</td>

and :

        RentalCarBL.CarBL bl = new RentalCarBL.CarBL ();

        List<Car> cars = bl.GetAll();

        rpCars.DataSource = cars;

        rpCars.DataBind();

it works fine on all the fields of the class Car all but one the category is a class in it self
how do i make it show the the inner field of the class Category (lets say Category.name)?

2

There are 2 answers

0
user1246950 On

well it seems i had a problem with the DAL but after fixing it still had the problem
but it was sort of easy to fix sens he told me it return the object all i had to do is override the tostring of the Category :) and it workt fine

1
iimax On
DataBinder.Eval(Container.DataItem, "Category") 

returns an object type.

You should convert it to your category's class type first. such as

((YourCategoryClassName)DataBinder.Eval(Container.DataItem, "Category")).CategoryName