StrataFrame Forum

ListView Requery Failing

http://forum.strataframe.net/Topic14334.aspx

By Bill Cunnien - 2/12/2008

I am trying to setup another listview with a bunch of open orders for a specified customer.  Sounds simple.  The listview utilized a Fill method that takes the custindex.  If the current BO has data (including a custindex number) then I call the requery method of the listview.  Here is the error on the ListView.Requery(custindex):

FormatException
  Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Source     : mscorlib

Stack Trace:
   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListView.CreateListViewItem(BusinessLayer BusinessObject)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListView.PopulateListView(Object[] Parameters)
   at MicroFour.StrataFrame.UI.Windows.Forms.ListView.Requery(Object[] Parameters)
   at Aspire.Accounting.CreditApproval.mSalesOrderUnderReviewBO_Navigated(NavigatedEventArgs e) in C:\Aspire Projects\AspireSF\Aspire.Accounting\CreditApproval.cs:line 41
   at MicroFour.StrataFrame.Business.BusinessLayer.NavigatedEventHandler.Invoke(NavigatedEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.raise_Navigated(NavigatedEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.OnNavigated(NavigatedEventArgs e)
   at MicroFour.StrataFrame.Business.BusinessLayer.Navigate(BusinessNavigationDirection Direction, Int32 AbsoluteIndex, Object[] PrimaryKeyValues, Boolean AttemptToCheckRules, Boolean IsRefill)
   at MicroFour.StrataFrame.Business.BusinessLayer.OnCurrentDataTableRefilled()
   at MicroFour.StrataFrame.Business.BusinessLayer.ChangeCurrentDataTable(DataTable NewTable, Boolean AcceptChanges, Boolean IsSharedTable)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillOrGetByPrimaryKey(Object[] PrimaryKeyValues, Boolean ReplaceCurrentDataTable)
   at MicroFour.StrataFrame.Business.BusinessLayer.FillByPrimaryKey(Int32 PrimaryKeyValue)
   at Aspire.Accounting.CreditApproval.NewOrderListView_DoubleClick(Object sender, EventArgs e) in C:\Aspire Projects\AspireSF\Aspire.Accounting\CreditApproval.cs:line 54
   at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
   at System.Windows.Forms.ListView.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Where do I start looking to solve this one?

Thanks,
Bill

By Trent L. Taylor - 2/12/2008

In line 41 of CreditApproval.cs you are calling a Requery and passing the parms. The first recommendation that I have is to use the ListPopulating event of the ListView instead of passing the parms in the Requery method so if you end up needing to requery from another location in code later you do not have to supply the parms....but this is not what is causing the probem.

The error is occuring when trying to create a list item.  This is a FormatException which means that it is more than likely coming from one of your properties that displays within the list.  Especially if you have a custom property.

The first thing I would do is make sure that I have a record in my BO and that all of the fields that are shown in the results of the list are valid (i.e. manually try to access each of the properties).  You can put a breakpoint in the Get of each of the properties that are used so you can see what is being return.  Finally, I am guessing that you may have typed in something wrong in the format of the column (i.e. the area where enter the display format {0}, {1}, etc).  You may have entered an illegal value not supported by the String.Format command.

By Bill Cunnien - 2/13/2008

Thanks, Trent,

That was the problem...one of the columns was not getting fed the proper data. 

Have a good day!
Bill

By Trent L. Taylor - 2/13/2008

Glad you found your problem Smile