Eval in DataList, DataGrid, and Repeater
Yesterday in the "Coolness of SubSonic" post I had a bit of asp.net markup (as I call it) that would display data in a data list from the data source. It specifically used.
<%# Eval("Name") %>
For a long time I have wondered how that worked I could never seem to figure it out until yesterday. Basically, you have an object that you bind to the data control like a datalist. In the case yesterday it was a Product class Object:
Well in the asp.net markup that we have below:
Notice in the Eval part it uses Name also notice from the product class above there is a name property. What ever property the object has you can use that in the Eval and it will display the data in there that comes from our collection of objects. In this case the Name property of our collection of Product Objects.
I know this wasn't a "cool" post, but it is something I was excited to finally understand so I thought I would post on it to help others understand hopefully.