- Everything about the RadTreeView seems to work just fine.
- The RadGrid Columns are created programtically whilst the rest of the radGrad is done design time.
- Eight of the thirteen or so columns are GridTemplateColumns.
The page keeps giving me an error after the page has rendered in the browser when it tries to seemingly instantiate this simple custom remove link. The error comes in the line here and caused by the fact that cItem.DataItem has a null value. Keep in mind the code has passed through the same code path twice already (prior to the rendering) and it is not until this third time (post-render) that the cItem.DateItem is set to nul. Another interesting note, the KeyValues remains unchanged ( KeyValues "{BuildGuid:\"7278f75e-4712-8f38-c598-b9a144c2a9fc\"}" string) in all three passes through the code path during the life cycle of the page.
Link.CommandArgument = (string)((DataRowView)cItem.DataItem)["BuildGuid"].ToString(); |
Here is the entire template object:
public partial class BuildRemoveLinkButton : ITemplate |
{ |
protected LinkButton Link; |
private string ColumnName; |
public BuildRemoveLinkButton(string ColumnNameInput) |
{ |
this.ColumnName = ColumnNameInput; |
} |
public void InstantiateIn(Control container) |
{ |
GridDataItem cItem = container.Parent as GridDataItem; |
if (cItem != null) |
{ |
Link = new LinkButton(); |
Link.Text = "remove"; |
Link.ToolTip = "Remove this build from the view"; |
Link.CommandArgument = (string)((DataRowView)cItem.DataItem)["BuildGuid"].ToString(); |
Link.ID = String.Format("Remove-{0}", this.ColumnName); |
Link.CommandName = ColumnName; |
container.Controls.Add(Link); |
} |
} |
} |
Just to remind you, the page and RadGrid have already rendered in the browser. Here is the RadGrid defintion:
<telerik:RadGrid ID="CompareGrid" runat="server" AutoGenerateColumns="false" |
ShowStatusBar="true" AllowSorting="true" OnNeedDataSource="CompareGrid_NeedDataSource" |
OnItemCommand="CompareGrid_ItemCommand" EnableViewState="false"> |
<MasterTableView DataKeyNames="BuildGuid" Width="680" CommandItemDisplay="Top" |
EnableColumnsViewState="false"> |
<HeaderStyle HorizontalAlign="Center"/> |
<ItemStyle HorizontalAlign="Center" /> |
<AlternatingItemStyle HorizontalAlign="Center" /> |
<CommandItemTemplate> |
<telerik:RadToolBar ID="CompareToolBar" runat="server" |
OnButtonClick="CompareToolBar_OnButtonClick"> |
<Items> |
<telerik:RadToolBarButton |
Text="Add all builds from tree" |
CommandName="ShowAll" /> |
<telerik:RadToolBarButton IsSeparator="true" /> |
<telerik:RadToolBarButton |
Text="Remove all builds from grid" |
CommandName="ShowAll" /> |
</Items> |
</telerik:RadToolBar> |
</CommandItemTemplate> |
</MasterTableView> |
<ClientSettings> |
<Scrolling AllowScroll="true" UseStaticHeaders="true" /> |
<ClientEvents OnColumnCreated="GridCreated" /> |
</ClientSettings> |
</telerik:RadGrid> |
Here also is the column creation code which is called during Page_Init:
private void CompareGrid_DefineGrid() |
{ |
// Create the columns for the Grid. |
// Add LinkButton column. |
GridTemplateColumn removeColumn = new GridTemplateColumn(); |
removeColumn.ItemTemplate = new BuildRemoveLinkButton("BuildRowRemove"); |
removeColumn.UniqueName = "BuildRowRemove"; |
removeColumn.DataField = "BuildRowRemove"; |
CompareGrid.MasterTableView.Columns.Add(removeColumn); |
// Add columns programtically. |
GridBoundColumn boundColumn = new GridBoundColumn(); |
boundColumn.UniqueName = "BuildName"; |
boundColumn.DataField = "BuildName"; |
boundColumn.HeaderText = "Build Name"; |
CompareGrid.MasterTableView.Columns.Add(boundColumn); |
// Add checkbox column. |
GridTemplateColumn checkColumn = new GridTemplateColumn(); |
checkColumn.HeaderTemplate = new HeaderCheckBox(); |
checkColumn.ItemTemplate = new BuildSelectCheckBox("BuildSelect"); |
checkColumn.UniqueName = "BuildSelect"; |
checkColumn.HeaderText = "Build Select"; |
checkColumn.DataField = "BuildSelect"; |
CompareGrid.MasterTableView.Columns.Add(checkColumn); |
// Add build guid hidden column. |
boundColumn = new GridBoundColumn(); |
boundColumn.UniqueName = "BuildGuid"; |
boundColumn.DataField = "BuildGuid"; |
boundColumn.Display = false; |
boundColumn.HeaderText = "Build Guid"; |
CompareGrid.MasterTableView.Columns.Add(boundColumn); |
// Add columns for each gate. |
GridTemplateColumn buttonColumn; |
foreach (GateDefinition definition in RIGates.Gates) |
{ |
buttonColumn = new GridTemplateColumn(); |
buttonColumn.ItemTemplate = new GateResultImageButton(definition.DataName); |
buttonColumn.HeaderTemplate = new GateCompareLinkButton(definition.DataName, definition.Name); |
buttonColumn.UniqueName = definition.DataName; |
buttonColumn.DataField = definition.DataName; |
buttonColumn.Reorderable = true; |
CompareGrid.MasterTableView.Columns.Add(buttonColumn); |
} |
} |
Finally, here is the call stack causeing the error after the page has rendered...
> BuildQuality.DLL!BuildQuality.Templates.BuildRemoveLinkButton.InstantiateIn(System.Web.UI.Control container = {Telerik.Web.UI.GridTableCell}) Line 53 C# |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridTemplateColumn.InitializeCell(System.Web.UI.WebControls.TableCell cell = {Telerik.Web.UI.GridTableCell}, int columnIndex = 2, Telerik.Web.UI.GridItem inItem = {Telerik.Web.UI.GridDataItem}) + 0x23d bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridItem.Initialize(Telerik.Web.UI.GridColumn[] columns = {Telerik.Web.UI.GridColumn[16]}) + 0x91 bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridItem.SetupItem(bool dataBind = false, object dataItem = null, Telerik.Web.UI.GridColumn[] columns = {Telerik.Web.UI.GridColumn[16]}, System.Web.UI.ControlCollection rows = {System.Web.UI.WebControls.Table.RowControlCollection}) + 0xdb bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridItemBuilder.InitializeItem(int dataSourceIndex = 0, out string nextItemHierarchicalIndex = "0", out bool itemIsInEditMode = false) + 0xfc bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridItemBuilder.CreateItems(Telerik.Web.UI.GridGroupingContext group = {Telerik.Web.UI.GridGroupingContext}) + 0x243 bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridTableView.CreateItems(System.Collections.IEnumerator enumerator = {Telerik.Web.UI.GridDummyDataSource.GridDummyDataSourceEnumerator}, Telerik.Web.UI.GridColumn[] columns = {Telerik.Web.UI.GridColumn[16]}, System.Web.UI.ControlCollection controls = {System.Web.UI.WebControls.Table.RowControlCollection}) + 0xc2 bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridTableView.CreateControlHierarchy(bool useDataSource = false) + 0x647 bytes |
Telerik.Web.UI.DLL!Telerik.Web.UI.GridTableView.CreateChildControls(System.Collections.IEnumerable dataSource = {System.Web.UI.WebControls.DummyDataSource}, bool useDataSource = false) + 0x33a bytes |
System.Web.dll!System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() + 0xa2 bytes |
System.Web.dll!System.Web.UI.Control.EnsureChildControls() + 0x67 bytes |
System.Web.dll!System.Web.UI.Control.FindControl(string id = "CompareGrid$ctl00$ctl02$ctl00$CompareToolBar", int pathOffset = 18) + 0x15 bytes |
System.Web.dll!System.Web.UI.Control.FindControl(string id, int pathOffset) + 0x16e bytes |
System.Web.dll!System.Web.UI.Control.FindControl(string id, int pathOffset) + 0x16e bytes |
System.Web.dll!System.Web.UI.Page.FindControl(string id) + 0x27 bytes |
System.Web.dll!System.Web.UI.Page.ProcessPostData(System.Collections.Specialized.NameValueCollection postData, bool fBeforeLoad = true) + 0x2c6 bytes |
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint = true, bool includeStagesAfterAsyncPoint = true) + 0x36f bytes |
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint = true) + 0x8d bytes |
System.Web.dll!System.Web.UI.Page.ProcessRequest() + 0x4f bytes |
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) + 0x16 bytes |
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) + 0x32 bytes |
App_Web_dsf31s5x.dll!ASP.default_aspx.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}) + 0x33 bytes C# |
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x65 bytes |
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = true) + 0x4c bytes |
System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) + 0x13e bytes |
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0xad bytes |
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr = {Microsoft.VisualStudio.WebHost.Request}) + 0x1a2 bytes |
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x7d bytes |
System.Web.dll!System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr) + 0x47 bytes |
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Request.Process() + 0x17b bytes |
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Microsoft.VisualStudio.WebHost.Connection conn = {System.Runtime.Remoting.Proxies.__TransparentProxy}) + 0x6c bytes |
[Appdomain Transition] |
WebDev.WebHost40.dll!Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(object acceptedSocket) + 0x83 bytes |
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x2d bytes |
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes |
[Native to Managed Transition] |
[Managed to Native Transition] |
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6a bytes |
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x7e bytes |
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x5a bytes |
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x147 bytes |
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x2d bytes |
[Native to Managed Transition] |
Any help/insights someone may have will be greatly appreciated.