The background calls databind (), and the foreground can use the eval function to bind data in the form of <% # %>.
As follows:
<% # Eval ("created", "{0: d}") %> // name of the created Field <br/> <% # parsedate (eval ("created ")) %> // parsedate background Method
You can use the background method to replace eval as follows:
Public object parse <tsource> (func <tsource, string> parseor) <br/>{< br/> var item = getdataitem (); <br/> return parseor (tsource) item); <br/>}< br/> protected void page_load (Object sender, eventargs E) <br/>{< br/> List <userinfo> List = new list <userinfo> <br/>{< br/> New userinfo {name = "Lin ", age = 25, created = datetime. now },< br/> New userinfo {name = "lin2", age = 25, created = datetime. now },< br/> New userinfo {name = "lin3", age = 25, created = datetime. now} <br/>}; <br/> repeater1.datasource = List; <br/> repeater1.databind (); <br/>}
The front-end calls the parse method as follows:
<Asp: repeater id = "repeater1" runat = "server"> <br/> <itemtemplate> <br/> <% # parse <userinfo> (u => string. format ("Name: {0} -- Age: {1}", U. name, U. age) %> <br/> </itemtemplate> <br/> </ASP: repeater>
The generic and delegated methods are more flexible and can be used at the front-end.Lambda expressions.