How to set inner object Data property for a datagridview

I have created Entity Framework for a model. I would like to access inner object and bind that inner object to a datagridview. I can access inner object but i cant set data property of datagridview to show this. Can any one please help me out Here the code I have two classes in EF. ItemMaster And Category.ItemMaster Contains Category Id.Category Contains Category Name. now in EF i can access Category Object like

 public static List<ItemMaster> GetAllItemMasters()
 {
 using (var itemContext = new EntitiesContext())
 {
        var items = itemContext.ItemMasters.Include("Category").Where(p=>  (p.IsDelete==   null || p.IsDeleted.Value == false)).ToList();
        return items;
    }

now while binding to a datagridview i have only properties like categoryid in code behind i can access inner object like itemmaster.category.categoryname but i cant set data property of datagridview as category.categoryname. So can you please help me out

Answers


Add a reference to your namespace (if needed), then unbox the item into the parent class.

((MyClass)Container.DataItem).MyInnerClassObject.SomePropertyValue

Need Your Help

send command to a printer via USB with C / C++ in windows

c++ c windows usb thermal-printer

I have a printer (Sewoo T320). I want to send commands via USB. I found a manual that shows some commands. How can I use them and print something with C/C++ in windows.

How to add a Layout / Design Exception programmatically

exception magento layout

I want to add an exception to the layout (as it is possible in www.url.de/admin/system_config/edit/section/design/ under the point themes). The thing is that I want to add this "add Exception" via ...