Note that there are some explanatory texts on larger screens.

plurals
  1. POFramework for ASP.NET data-binding wrapper classes
    primarykey
    data
    text
    <p>Apparently <a href="http://newcome.wordpress.com/2010/06/05/dynamic-objects-in-c/" rel="nofollow">ASP.NET doesn't allow data-binding to dynamic objects</a>. Major bummer, because I could see a syntax like this being really useful:</p> <pre><code>public class User { public string FirstName { get; set; } public string LastName { get; set; } } ... // No this doesn't exist, I just wish it did! MyGrid.DataSource = GetAllUsers() .AsDynamic() .WithProperty("FullName", user =&gt; user.FirstName + " " + user.LastName) .ToEnumerable(); // returns IEnumerable&lt;dynamic&gt; MyGrid.DataBind() ... &lt;asp:BoundField DataField="FirstName" HeaderText="First Name" /&gt; &lt;asp:BoundField DataField="LastName" HeaderText="Last Name" /&gt; &lt;asp:BoundField DataField="FullName" HeaderText="Full Name" /&gt; </code></pre> <p>In this example, <code>AsDynamic()</code> would return a class that would configure the dynamic objects that would be returned by <code>.ToEnumerable()</code> later (because <a href="http://blogs.msdn.com/b/cburrows/archive/2009/02/04/c-dynamic-part-vii.aspx" rel="nofollow">you can't implement <code>IEnumerable&lt;dynamic&gt;</code></a>) effectively adding properties to the wrapped data object. The requests for FirstName and LastName would be "served" by the real object, and the request for FullName would be routed to a delegate or expression to be evaluated dynamically.</p> <p>This is a trivial example, because in most cases you could easily add a FullName property to the User object, and you could easily pull this off with a TemplatedField.</p> <p>But what if the added property was way too difficult to implement in a TemplatedField without several lines of databinding codebehind? And what if you didn't control the source code for the User class? Or what if you can't add the property to User because its calculation is dependent on an assembly which itself depends on User's assembly? (circular reference problem)</p> <p>For this reason it would be great to have a very easy-to-apply data binding wrapper such as this, where you don't have to generate a brand new class every single time.</p> <p><strong>So what am I really after?</strong></p> <p>Are there any frameworks or techniques out there that allow this kind of thing? The exact syntax above isn't really important, just the ability to dynamically add stuff to classes and use those proxies in data-binding, without a bunch of manual plumbing code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload