Binding to DataView

Posted by: bobfisher on 8 September 2017, 1:52 pm EST

  • Posted 8 September 2017, 1:52 pm EST

    I just downloaded version 4.0 and was using an older version before.


    I'm having trouble when binding to a DataView.  After binding, if I try to set a cell value I get a null reference exception.  When I change to binding to the DataTable the null reference exception goes away.


    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> Form1_Load(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.Load


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> dt </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> DataTable</FONT>


    <FONT size=2>dt.Columns.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"String"</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>GetType</FONT></FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>String</FONT></FONT><FONT size=2>))


    dt.Columns.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Int"</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>GetType</FONT></FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Integer</FONT></FONT><FONT size=2>))


    dt.Columns.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Date"</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>GetType</FONT></FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Date</FONT></FONT><FONT size=2>))


    dt.Rows.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"a"</FONT></FONT><FONT size=2>, 0, System.DateTime.Now)


    dt.Rows.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"b"</FONT></FONT><FONT size=2>, 1, System.DateTime.Now)


    dt.Rows.Add(</FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"c"</FONT></FONT><FONT size=2>, 2, System.DateTime.Now)


    dt.AcceptChanges()


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.FpSpread1.DataSource = dt.DefaultView


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.FpSpread1.Sheets(0).Cells(0, 0).Value = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"ABC"        <FONT color=#009900>'<---- Generates a NULL reference exception.  If I bind to the datatable instead, this works</FONT>

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub

    </FONT></FONT>

    Here is the exception:


     


    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="FarPoint.Win.Spread"
      StackTrace:
           at FarPoint.Win.Spread.Model.DefaultSheetDataModel.SetValue(Int32 row, Int32 column, Object value)
           at FarPoint.Win.Spread.Cell.set_Value(Object value)
           at Example.Form1.Form1_Load(Object sender, EventArgs e)


    etc.


    Thanks,


    Bob


     


     

  • Replied 8 September 2017, 1:52 pm EST

     


    Hello Bob,


    I have escalated the reported issue as a bug to our QA team to Fix. Hope it should be fixed in next maintenance release. Bug Number: <B>25666</B>


    Thanks,


    Deepak Sharma


     


     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels