Simple Databinding with LINQ causing Object reference not set...errorhttp://forums.asp.net/t/1590546.aspx/1?Simple+Databinding+with+LINQ+causing+Object+reference+not+set+errorSun, 15 Aug 2010 19:47:09 -040015905464028380http://forums.asp.net/p/1590546/4028380.aspx/1?Simple+Databinding+with+LINQ+causing+Object+reference+not+set+errorSimple Databinding with LINQ causing Object reference not set...error <p>I have a user control with a datalist.&nbsp; I just want to do some simple binding but&nbsp;keep getting an object reference not set to&nbsp;an instance of an object error.&nbsp;The following is&nbsp;the&nbsp;code, I am sure&nbsp;I am just missing something simple:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim dc As Forms.DataClassesDataContext = New Forms.DataClassesDataContext</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim formQuery = From fq In dc.v_form_questions _<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Where fq.FormTypeID = FormTypeID _<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select fq _<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Order By fq.SectionID, fq.Question</p> <p><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dlFormQuestions.DataSource = formQuery</p> <p>When I debug, I see values for the formQuery; I am also able to loop through the formQuery and response.write a field out, however every time I try to bind it to a databound control, I get the Object reference not set to an instance of an object error.</p> <p>I initally was using a simple LinqDataSource object, but needed to set the where parameter to the FormTypeID property of this usercontrol.&nbsp; I had a Where condition defined on Page Init, but started getting the object reference error.&nbsp; Any advice would be appreciated.</p> <p>Jayme</p> 2010-08-15T16:54:21-04:004028481http://forums.asp.net/p/1590546/4028481.aspx/1?Re+Simple+Databinding+with+LINQ+causing+Object+reference+not+set+errorRe: Simple Databinding with LINQ causing Object reference not set...error <p>The error was actually just a silly mistake as I was loading the control into the placeholder.&nbsp;&nbsp;Once I corrected the&nbsp;loading of the user control, all works&nbsp;as intended.&nbsp;</p> 2010-08-15T19:47:09-04:00