Geeks With Blogs
Ben Adler's Development Posting solutions as I find them
I had a form view where I was binding two different objects to. These two objects were slightly different, and I didn't want to create a separate form view for both objects.

Here is what I did:

<%# Container.DataItem.GetType().GetProperty("Property1") != null ? DataBinder.Eval(Container.DataItem, "Property1") : DataBinder.Eval(Container.DataItem, "Property2")  %>

Posted on Wednesday, April 22, 2015 11:23 AM C# | Back to top

Comments on this post: C# Check if property exists before binding

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © BenAdler | Powered by: