StrataFrame Forum

Browse Dialog and Custom Fields

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

By Kevin Lingofelter - 9/27/2006

I have a few custom (read-only) fields in a BO that works great when binding to controls.

I am having problems trying to use these fields inside a BrowseDialog control. I can select the fields to be searched, but when I try to search on one of those fields, I get the following error:

KeyNotFoundException
 The given key was not present in the dictionary.

Source     : mscorlib

Stack Trace:
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.BuildWhereElement(Int32 ParameterIndex)
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.BuildSearchWhereClause()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.Search()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogWindow.ExecuteSearch()
   at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogSearchToolStrip.cmdSearch_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.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)

Do I need to add something to the BO to allow custom fields to be searched?

Thanks!

By StrataFrame Team - 9/27/2006

Ah, you cannot use a custom property as a search field because the search fields are directly translated back to the query that is executed on SQL Server.  So, if the column does not exist on SQL Server, the browse dialog cannot use the field as a search field because a) it doesn't know how to build a parameter for the field, and b) SQL Server would say the column didn't exist.
By Kevin Lingofelter - 9/27/2006

Thud...Forehead has been smacked...=)

It is possible to override the search logic in the browseDialog? It would be nice to define a method in the BO which can be used to return search results.

Kevin

By Trent L. Taylor - 9/27/2006

As of right now you cannot overwrite the browse logic.  We have thought about adding an event to allow stored procedures and the overwrite of the query information.  But this is probably a ways out. Ermm  Sorry.