DataGrid Control, when itemtemplate displays data,
What is the difference between databinder. eval_r (container. dataitem, "name") and container. dataitem ("name?
Databinder is system. A static class in the Web, which provides the eval method to simplify writing data binding expressions. However, it uses reflection and other overhead methods to achieve ease of use, therefore, its performance is not the best.
Container is not a static object or method at all. It is processed by the ASP. NET page compiler in the Data Binding event.ProgramLocal variables declared internally are data container types of controls that can be bound to data (for example, the data binding container inside repeater is called repeateritem ), dataitem attributes are basically available in these container classes.
Therefore, you can write container. dataitem. This attribute returns the data item from the data source you are bound. If your data source is datatable, the Data Type of this data item is actually datarowview. High Efficiency!
Commonly used databinder Method
<% # Databinder. eval_r (container. dataitem, "columnname") %>
<% # Databinder. eval_r (container. dataitem, "columnname", null) %>
<% # Databinder. eval_r (container, "dataitem. columnname", null) %>
method used by the container
<% # (datarowview) container. dataitem) ["columnname"] %>
<% # (datarowview) container. dataitem ). row ["columnname"] %>
<% # (datarowview) container. dataitem) ["adtitle"] %>
<% # (datarowview) container. dataitem) [N] %>
<% # (dbdatarecord) container. dataitem) [0] %>
<% # (custom type) container. dataitem )). attribute. tostring () %> // If the attribute is of the string type, you do not need tostring ().