Recently, I felt that the data binding controls were messy. I wanted to tell you all about them, but I just wanted to open my mouth and found that I didn't have a complete concept in my mind, I will summarize it myself. I don't know it's all.
Here, there are four concepts: the container control that you want to bind data refers to the parent control, dataitem refers to the current row of the data source bound to the parent control, and eval and bind are not mentioned here.
Assume that there are two data sources: 1. A generic class list <student> or datatable
They all have a field ID.
1. <% # eval ("ID") %> (these are also three methods)
2. <% # (student) container. dataitem). Id %>
3. <% # (system. Data. datarowview) container. dataitem) ["ID"]. tostring () %>
4. <asp: Label id = "label1" runat = "server" text = '<% # (student) container. dataitem). Id %>'>
5. <asp: Label id = "label1" runat = "server" text = '<% # (system. data. datarowview) container. dataitem) ["ID"]. tostring () %> '>
6. <asp: Label id = "label1" runat = "server" text = '<% # databinder. eval (container, "dataitem. ID") %>'>
7. <asp: Label id = "label1" runat = "server" text = '<% # databinder. eval (container. dataitem, "ID") %>'>
8. <asp: Label id = "label1" runat = "server" text = '<% # eval ("ID") %>'> </ASP: Label>
Here I will not write the bind.