I am working with emulating the RadGrid demo found here: Grid Demo - Hierarchy. I am able to attach to the w3wp.exe process to debug and even get inside the event 'ItemDataBound' when it is raised. Instead of using the control SQLDataSource I in turn am using a DataSet populated with DataTables. Here is my code for my webpart:
The link between the two tables (Tables are named "DocTable" and "SPOCTable") is the column "ID". When this control is displayed on the page, the first table shows up fine. The second table however, doesnt show up at all. The hierarchal demo is really cool and useful for what we want but I just do not understand what is going on.
J
protected override void CreateChildControls() |
{ |
base.CreateChildControls(); |
try |
{ |
da = new DataAccess(); |
strArea = "SubSite Name"; |
strListName = "List Name"; |
strView = "All Documents"; |
ds = da.GetListData(strArea, strListName, strView); |
this.EnsureUpdatePanelFixups(); |
UpdatePanel up = new UpdatePanel(); |
up.ID = "UpdatePanel1"; |
up.ChildrenAsTriggers = true; |
up.UpdateMode = UpdatePanelUpdateMode.Conditional; |
this.Controls.Add(up); |
// Example of adding RadGrid to Moss 2007 site using a RadGrid |
// ************************************************************* // |
rdDocs = new RadGrid(); |
rdDocs.ID = "rdDocs"; |
rdDocs.DetailTableDataBind += new GridDetailTableDataBindEventHandler(rdDocs_DetailTableDataBind); |
rdDocs.ItemCommand += new GridCommandEventHandler(rdDocs_ItemCommand); |
rdDocs.ItemDataBound += new GridItemEventHandler(rdDocs_ItemDataBound); |
rdDocs.PageSize = 30; |
rdDocs.AllowPaging = true; |
rdDocs.AllowSorting = true; |
rdDocs.GridLines = GridLines.None; |
rdDocs.ShowStatusBar = true; |
rdDocs.PagerStyle.Mode = GridPagerMode.NumericPages; |
rdDocs.AutoGenerateColumns = false; |
GridBoundColumn gbcID = new GridBoundColumn(); |
GridBoundColumn gbcLinkFileName = new GridBoundColumn(); |
GridBoundColumn gbcPrimaryPOC = new GridBoundColumn(); |
gbcID.DataField = "ID"; |
gbcID.HeaderText = "Document ID"; |
gbcID.Visible = false; |
gbcLinkFileName.DataField = "LinkFilename"; |
gbcLinkFileName.HeaderText = "Documents"; |
gbcPrimaryPOC.DataField = "Primary_x0020_POC"; |
gbcPrimaryPOC.HeaderText = "Primary POC"; |
rdDocs.Columns.Add(gbcID); |
rdDocs.Columns.Add(gbcLinkFileName); |
rdDocs.Columns.Add(gbcPrimaryPOC); |
rdDocs.Width = Unit.Percentage(95); |
rdDocs.DataSource = ds.Tables[0]; |
rdDocs.DataBind(); |
up.ContentTemplateContainer.Controls.Add(rdDocs); |
// ************************************************************* // |
// Example of adding RadGrid to Moss 2007 site using a RadGrid |
// ************************************************************* // |
GridTableView rdSndPOCs = new GridTableView(); |
GridTableViewRelation gtvrSndPOCs = new GridTableViewRelation(); |
rdSndPOCs.ID = "rdSndPOCs"; |
rdSndPOCs.Caption = "Secondary POCs"; |
GridRelationFields grfSndPOCs = new GridRelationFields(); |
grfSndPOCs.DetailKeyField = "ID"; |
grfSndPOCs.MasterKeyField = "ID"; |
rdDocs.MasterTableView.ParentTableRelation.Add(grfSndPOCs); |
gtvrSndPOCs.Add(grfSndPOCs); |
rdSndPOCs.PageSize = 30; |
rdSndPOCs.AllowPaging = true; |
rdSndPOCs.AllowSorting = true; |
rdSndPOCs.GridLines = GridLines.None; |
rdSndPOCs.PagerStyle.Mode = GridPagerMode.NumericPages; |
rdSndPOCs.AutoGenerateColumns = false; |
gbcID = new GridBoundColumn(); |
GridBoundColumn gbcSecondaryPOC = new GridBoundColumn(); |
gbcID.DataField = "ID"; |
gbcID.HeaderText = "Document ID"; |
gbcID.Visible = true; |
gbcSecondaryPOC.DataField = "SecondaryPOC"; |
gbcSecondaryPOC.HeaderText = "Secondary POC"; |
rdSndPOCs.Columns.Add(gbcID); |
rdSndPOCs.Columns.Add(gbcSecondaryPOC); |
rdSndPOCs.Width = Unit.Percentage(95); |
rdSndPOCs.DataSource = ds.Tables[1]; |
rdSndPOCs.DataBind(); |
rdDocs.MasterTableView.DetailTables.Add(rdSndPOCs); |
} |
catch (Exception ex) |
{ |
Context.Response.Write(ex.Message); |
} |
} |
void rdDocs_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) |
{ |
string str = ""; |
} |
void rdDocs_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
strTest += e.Item.ItemIndex + "<br>"; |
} |
void rdDocs_ItemCommand(object source, GridCommandEventArgs e) |
{ |
//throw new NotImplementedException(); |
if (e.CommandName == "ExpandCollapse") |
{ |
DataTable dt = (DataTable)e.Item.OwnerTableView.DataSource; |
if ((dt != null) && (dt.TableName == "DocTable")) |
{ |
GridTableView detailView = (e.Item as GridDataItem).ChildItem.NestedTableViews[1]; |
detailView.Visible = false; |
} |
} |
} |
The link between the two tables (Tables are named "DocTable" and "SPOCTable") is the column "ID". When this control is displayed on the page, the first table shows up fine. The second table however, doesnt show up at all. The hierarchal demo is really cool and useful for what we want but I just do not understand what is going on.
J