Hello --
I am using the following to populate a datagrid and to setup hierarchical relationships for a parent/child grid:
private void radButton1_Click(object sender, EventArgs e) { FlexEDIEntities db = new FlexEDIEntities(); var gridData = (from d in db.billing_transactions where d.status == 1 select new { d.Id, d.stop_details.con_name, d.stop_details.con_address1, d.stop_details.con_city, d.weight_billed, d.base_amount, count = d.billing_transaction_accessorial_charge.Count }).ToList(); main_grid.DataSource = gridData; if (this.main_grid.Relations.Count == 0) // does not exist yet { GridViewRelation relation = new GridViewRelation(this.main_grid.MasterTemplate); relation.ChildTemplate = accessorial_template; relation.RelationName = "TransToCharges"; relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("billing_transaction_id"); this.main_grid.Relations.Add(relation); } }
I have a lot of these to do in this project so I am trying to not have to have a bunch of extra data sources in the project.
It is not necessary that the datagrid update the underlying data source as edits will be handled by dedicated screens.
Can I set up the child data source using a linq query, either by modifying the one above or having a second one that is dedicated for the child relationship?
Thank you --
Joe
