Combobox not populating when on a SF User Control


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Any time. I understand about limited time. You'll get it soon enough Hehe



As to the IsDirty question. My understanding is that it should be set to false after a save. I do know that it is just looking at the datatable that the BO wraps. Ben (or Trent if he's back) will have to field that one. It doesn't make any sense to me.



StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Greg is correct about the use of DirectCast vs CType in VB.  DirectCast tells the compiler to try casting the object and then check for implcit/explicit casting operators on the two types in question (the one being cast and the requested type) while CType tells the compiler to try casting it first, and then check for an implicit/explicit conversion operators, and then try the Convert.ToXXX methods for backward compatibility with old VB, so in some cases, CType is slower Smile.  Nice one Greg.

However, jjp, you're using C#, which doesn't have DirectCast or CType, it just has the cast syntax like C++:

string var = (string)someOtherVar;

or

object var = new SomeType();
((SomeType)var).SomeMethodOnThatType();

So, in C#, the casting operator is the equivalent to DirectCast (though the C# compiler will pick up on a few extra things that DirectCast won't).  There is no equivalent to CType, but since it's really meant for backward compatibility with old VB, and since the C# casting picks up on a few cases where DirectCast won't you don't really need it.

One other casting worth mentioning is the "as" (C#) / TryCast (VB):

object var = new SomeType();
SomeType var2 = var as SomeType;

Dim var As Object = New SomeType()
Dim var2 As SomeType = TryCast(var, SomeType)

It can only be used with reference types (so no value types, structures, etc.).  But, it will never throw an exception (hence the "Try" in the name) and it's extremely fast.  It will try to cast the object, and if it fails, it returns null (Nothing in VB), hence why you need a reference type since value types cannot be null.  So, if you're not absolutely positive that your object is going to be a certain type, always TryCast (as) and then test your variable on null (Nothing).  That combination is actually just as fast as casting and is much faster than testing on the type of an object before casting it.  If you use Reflector and look through the .NET DLLs, you'll see them use it all the time.

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Oh, and I forgot jpp that in VB controls are marked with Friend (internal) while in C#, they're marked as private by default.  So, for the first sample of mine to work, you would need to change the modifier to either internal or public to see your combo box as a field directly on the form.
Jeff Pagley
Jeff Pagley
StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Thanks for the tip Ben.  In addition, I had an issue with the IsDirty property. See http://forum.strataframe.net/FindPost11280.aspx.

Thanks again.

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
That's strange.  The IsDirty property does not have a backing field.  Meaning that we don't store off the value anywhere.  Each time you call the get{} of the property, the CurrentDataTable of the business object is re-evaluated for dirty rows.  So, either one of the records is not being saved, or possibly, you're saving on a transaction.  If you save on a transaction, the changes do not get accepted until the transaction is comitted.  What I would check first is the return value of the Save() method.  It should return Success.  So, if it's returning CompletedWithExceptions or AbortedWithBrokenRules, the records are not actually being persisted to the database, and the business object will still be dirty.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks for the details on casting. I'm not using the TryCast enough... BigGrin
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