I have a TypedView that returns correct data if I loop through the rows and examine the data but if I try to bind it to a control (in my case a TreeView from Telerik) I get an Exception saying that one of the columns is Null.
I experimented and wrote a SPROC that uses the same SELECT (but adds a parameterized WHERE clause to replace the view's filter) and used the returned DataTable to bind to the control instead. This worked.
Is there a difference between a DataTable in a TypedView and SPROC result set or is this a bug?
Some details:
- LLBLGen Pro version "1.0.2005.1 Final".
- Runtime versions 2.0.50727 (SD.LLBLGen.Pro.SqlServer.NET20 and ...ORMSupportClasses.NET20)
- SQL Server 2005 engine
- Illustrative code ('this' is subclassed 3rd party treeview control):
if true
// THIS WORKS...
DataTable tempDataTable = RetrievalProcedures.SpTempforTesting(1);
this.DataSource = tempDataTable;
else
// THIS DOESN'T WORK....
TestingOfRadTreeViewDataBinding1TypedView goals = new TestingOfRadTreeViewDataBinding1TypedView();
IPredicate goalsFilter = new FieldCompareValuePredicate(TestingOfRadTreeViewDataBinding1Fields.TreeId,
ComparisonOperator.Equal,
1);
goals.Fill(0, null, true, goalsFilter);
this.DataSource = goals;
endif
this.DataFieldID = "Goal_ID";
this.DataFieldParentID = "ParentGoal_ID";
this.DataBind();
- The exception I get:
System.ArgumentNullException was unhandled by user code
Message="'column' argument cannot be null.\r\nParameter name: column"
Source="System.Data"
ParamName="column"
StackTrace:
at System.Data.DataKey..ctor(DataColumn[] columns, Boolean copyColumns)
at System.Data.DataRelation.Create(String relationName, DataColumn[] parentColumns, DataColumn[] childColumns, Boolean createConstraints)
at System.Data.DataRelation..ctor(String relationName, DataColumn parentColumn, DataColumn childColumn, Boolean createConstraints)
at System.Data.DataRelationCollection.Add(String name, DataColumn parentColumn, DataColumn childColumn, Boolean createConstraints)
at Telerik.WebControls.RadTreeView.x0320846e8a4fe57b()
at Telerik.WebControls.RadTreeView.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at Kingsmere.Controls.GoalsTreeRadTreeView.FillUsingGoalsTypedView(GoalsForTreeDisplayTypedView goalsForTreeTypedView) in C:\Documents and Settings\Emmanuel\My Documents\Visual Studio 2005\Projects\Kingsmere\Kingsmere.UIHelper\GoalsTreeRadTreeView.cs:line 196
at Kingsmere.Controls.GoalsTreeRadTreeView.FillWithGoals(Int32 treeId, Boolean AddToExisting) in C:\Documents and Settings\Emmanuel\My Documents\Visual Studio 2005\Projects\Kingsmere\Kingsmere.UIHelper\GoalsTreeRadTreeView.cs:line 125
at Kingsmere.Controls.GoalsTreeRadTreeView.Populate(Int32 projectId, Guid userId) in C:\Documents and Settings\Emmanuel\My Documents\Visual Studio 2005\Projects\Kingsmere\Kingsmere.UIHelper\GoalsTreeRadTreeView.cs:line 69
at FluidMainTest1.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Emmanuel\My Documents\Visual Studio 2005\WebSites\Kingsmere\FluidMainTest1.aspx.cs:line 83
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
- The View query (when used in SPROC a 'WHERE dbo.Goals.Tree_ID = @param1' clause is added):
SELECT TOP (100) PERCENT dbo.Trees.Project_ID, dbo.Goals.Tree_ID, dbo.Goals.Goal_ID, dbo.Goals.ParentGoal_ID, dbo.Goals.TreeLevel,
dbo.Goals.PreOrder, dbo.Goal_Text.Goal_Title AS Text, dbo.Trees.ShareableWith
FROM dbo.Goals INNER JOIN
dbo.Goal_Text ON dbo.Goals.Goal_Text_ID = dbo.Goal_Text.Goal_Text_ID INNER JOIN
dbo.Trees ON dbo.Goals.Tree_ID = dbo.Trees.Tree_ID
ORDER BY dbo.Goals.Tree_ID, dbo.Goals.PreOrder