开发者

Databinding and Lists in instances of classes

I have initialised an instance of a class i have called "Relation" this class also contains a list of "Bills". When i databind this information to a grid, the Relations are showing, tho the Bills ain't. The Relation information is returning in a List and the Bills are inside.

Relation cRelation = new Relation();
List<tRelation> relationList = cRelation.getRelations(); 

a relation has:

relation.Bills <== List<tBills>;

How to 开发者_开发百科make sure that the list inside the list is also getting showed in the Datagrid?


You can't. Use a Master/Detail approach for this, Here's one approach: How to: Create Master/Detail Lists with the Windows Forms DataGrid Control


Put a GridView inside an ItemTemplate of your grid.

On RowDataBound of your first grid, get the inner grid for each row and apply databinding from the source list as follows:

Relation relation = (Relation) e.Row.DataItem;
GridView grdInner = (GridView) e.Row.FindControl("grdInner");
grdInner.DataSource = relation.Bills;
grdInner.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜