How do I bind a DevEx grid to a BO?


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

I've created a BO and want to bind it to a Dev Express Grid but I just can't work out how to.

I see that if I drop a SF control onto a form the control has a Business Object property that I can use but that property isn't available for a Dev Express Grid control. I've had a look at the Dev Express Wrapper sample (under ..\VB.Net Samples\EnhancedList) and see that Dev Express Grid doesn't have a Business Object property but the Grid's "Run Designer" button is greyed out so I can't see what is going on within the grid itself to see how the data binding is achieved.

Can you please point me in the right direction.

BTW I think your help file is pretty good but it would sure be a lot better if the search facility worked - no matter what search value I use it always returns "no topics found".

TIA - Peter

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Peter.

I've created a BO and want to bind it to a Dev Express Grid but I just can't work out how to.

Try dropping a SF BusinessBindingSource on your form. Set its BusinessObject to your BO. Then, you can set your Grid's DataSource to your BusinessBindingSource name.

BTW I think your help file is pretty good but it would sure be a lot better if the search facility worked - no matter what search value I use it always returns "no topics found".

I believe there was a problem and the guys posted a new help file with the fix. Follow this link and I guess you will be fine.

http://forum.strataframe.net/Topic5628-9-1.aspx#bm5893

Hope I could help.

Cheers.

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Once again, Ivan's on top of it.  The BBS is the answer to binding a business object to a grid.  And that link will take you to the corrected help file in which the full text search is fixed.
Peter Jones
Peter Jones
Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)Advanced StrataFrame User (520 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Thanks Ivan, that fixed the problem but, as you may imagine, another has surfaced. When I try to populate my BO with data with the code:

Private Sub boHID_ParentFormLoading() Handles Me.ParentFormLoading

Me.FillDataTable("SELECT tblHIDHides.* FROM tblHIDHides")

End Sub

I get an error on the FillDataTable line: "DataLayerException unhandled" along with the message: "An error occurred while creating a new DataLayer for the business object."

The Inner Exception tells me: "{"The DataSourceKey [] is not defined."}". In checking properties I see there is a DataSourceKey but, as I understand it from the Help Docs, when there is only one data source this value should be blank and mine is. I've copied and pasted the select string into QA in SQL 2005 and it executes ok.

My BO is mapped to a database table and I presume this is ok because my Dev Express grid has now been populated with all the columns in the table (after your previous advice).

Hope you can help.  TIA Peter

-----------------------------------------------------------

The exception details are:

MicroFour.StrataFrame.Data.DataLayerException was unhandled
  Message="An error occurred while creating a new DataLayer for the business object."
  Source="MicroFour StrataFrame Business"
  StackTrace:
       at MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer()
       at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement)
       at SF_Test06.boHID.boHID_ParentFormLoading() in C:\Documents and Settings\pmj\My Documents\Visual Studio 2005\Projects\SF_Test06\SF_Test06\boHID.vb:line 93
       at MicroFour.StrataFrame.Business.BusinessLayer.raise_ParentFormLoading()
       at MicroFour.StrataFrame.Business.BusinessLayer.OnParentFormLoading()
       at MicroFour.StrataFrame.Business.BusinessLayer.RaiseParentFormLoadingEvent()
       at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.InitializeFormLoadObjects()
       at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at SF_Test06.frmHID.Main() in C:\Documents and Settings\pmj\My Documents\Visual Studio 2005\Projects\SF_Test06\SF_Test06\frmHID.Designer.vb:line 2
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Peter.

I'm not sure I can help you here, but don't worry, if I get it wrong they will.

Does it work if you change your code so it looks like:

Private Sub boHID_ParentFormLoading() Handles boHID.ParentFormLoading

    Me.boHID.FillDataTable("SELECT * FROM tblHIDHides")

End Sub

 

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The problem is that your business object is expecting to find a DataSource with the DataSourceKey of "" within the DataSources collection, but it doesn't exist.  You need to check your AppMain.vb code file and look at the SetDataSources() method.  If you're using the ConnectionManager, then you need to check the first parameter in your AddRequiredDataSourceItem() call and make sure it's an empty string.  If you're adding the data source manually, you need to make sure the first parameter to the New SqlDataSourceItem() constructor call is an empty string.  These parameters define the DataSourceKey for the data source within the collection.  So, that value has to match the value on your business objects, which is why the template has an empty string for both of those values.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search