Exception on databinding TypedView DataTable (Column is Null)

Posts   
 
    
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 09-May-2006 16:06:17   

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:

  1. LLBLGen Pro version "1.0.2005.1 Final".
  2. Runtime versions 2.0.50727 (SD.LLBLGen.Pro.SqlServer.NET20 and ...ORMSupportClasses.NET20)
  3. SQL Server 2005 engine
  4. 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();
  1. 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)

  1. 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

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39885
Joined: 17-Aug-2003
# Posted on: 10-May-2006 10:26:17   

And when you add the filter to the fetch for the typedview? The TypedView IS a datatable, and is filled with a dataadapter from .NET, similar to what's used with the proc. I also fail to see what the cause is for this error...

Frans Bouma | Lead developer LLBLGen Pro
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 10-May-2006 22:14:20   

I put the filter in the View SELECT statement. No change - still got same exception.

I'll keep hunting. Must be something I've done.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-May-2006 07:25:46   

I guess this error means that a column name is not valid.

You may have changed a field's name/caption from the LLBLGen Pro Designer, and you you use the database field name in your databinding.

Make sure the field names you use in databinding are actually returned by the TypedView.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39885
Joined: 17-Aug-2003
# Posted on: 11-May-2006 09:41:04   

It seems to create a datarelation... that's strange, as it's fetching a datatable, how can it create a datarelation in a datatable? confused

Frans Bouma | Lead developer LLBLGen Pro