StrataFrame Forum

Error populating a listview...

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

By StarkMike - 7/26/2006

When trying to fill a Listview with a BO i get the following error:



Dynamically populating the ListView failed. Could not create and fill the business object of type 'STI.InventoryBO'.




I setup everything correctly, i think, not sure why I'm getting this error.



Any ideas?
By Trent L. Taylor - 7/26/2006

Does the method you selected require parameters?  If so you need to set those parameters in the ListPopulating event of the list.  There will be an event argument like this:

e.Parameters(0).Value = 1
e.Parameters(1).Value = "Second Parm"

By StarkMike - 7/26/2006

I did that. I fixed it. Not sure why this works. I'm sure you can explain it to me. Tongue



This is what I had when it wasnt working...

e.Parameters(0).Value = Me.txtPOID.Text




I changed it to this and it worked.

e.Parameters(0).Value = Cint(Me.txtPOID.Text)




Can you enlighten me as to why that conversion made a difference?
By Trent L. Taylor - 7/26/2006

It has to do with strong-typing.  Your method has a parameter defined as a System.Int32.  Any controls "Text" property is defined as a System.String.  By passing just the Control.Text, you are passing a string typed value and the method expects integer.  When you added the CInt(), it converted the text to Integer as the method was expecting.  .NET is a strong-typed development environment.  You cannot rely on automatic data conversions like other languages such as Visual FoxPro.  This is actually a VERY good thing.  You learn about type conversions either a compile time or very quickly when an app is run.  So most of the "Data Type Mistmatch" error from the old days are gone.

Just FYI, I would not use CInt().  It is very slow and is an obselete method.  You should do most of your type conversions like this:

CType(Control.Text, System.Integer)

By StarkMike - 7/26/2006

Thaks for the tip! I can ALWAYS use those!
By Trent L. Taylor - 7/26/2006

That's what we're here for! Wink