What is the difference between databinder. eval and container. dataitem?

Source: Internet
Author: User

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 ().

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.