Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
How Best to Bind this DataSet?
posted

Hello,

 

I have a list of objects that needs to be bound to a grid.  However, the default "behavior" is not what I need right now.

 

My object DataItem contains descriptive properties, and then a collection of 2 different DataSourceItems.  By default these DataSourceItems appears as a child of the DataItem in the grid.  What I would like to see is the properties of these 2 items appear in the same row as the DataItem which is bound to the grid, not as children.

 

Simplified object structure is as follows:

class DataItem

{

public int id { get; set; }

public List<DataSourceItem> List { get; set }

}

class DataSourceItem

{

public string Name { get; set; }

public string Value { get; set; }

}

 

Any suggestions would be great, let me know if this is overly vague.

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    To achieve this you would have to use UnboundFields which can work with indexers.

    You should use the BindingPath property of the UnboundField and set it to something like:

     BindingPath="PropertyName[index].PropertyName"

    example : BindingPath="List[X].Name"

    In addition to this, please make sure that the AutoGenerateFields property of the FieldLayoutSettings is set to false and you define the field layouts manually.

Children
No Data