的分析,我们把目光集中绑定代码上。假设现在页面上有这 么一段Repeater绑定代码:
1: <asp:Repeater runat="server" ID="repeater">
2: <HeaderTemplate>
3: <table>
4: <tr>
5: <td>
6: ID
7: </td>
8: <td>
9: 电流{a}
10: </td>
11: <td>电 压(V)</td>
12: <td>
13: 备注''
14: </td>
15: <td>
16: 名称]
17: </td>
18: </tr>
19: </HeaderTemplate>
20: <ItemTemplate>
21: <tr>
22: <td>
23: <%# Eval("ID")%>
24: </td>
25: <td>
26: <%# Eval("电流{a}")%>
27: </td>
28: <td><%# Eval("电压(V)")%></td>
29: <td>
30: <%# Eval("备注''")% >
31: </td>
32: <td>
33: <%# Eval("名称]")%>
34: </td>
35: </tr>
36: </ItemTemplate>
37: <FooterTemplate>
38: </table>
39: </FooterTemplate>
40: </asp:Repeater>
那么在动态类中,相应的会有这样的一段函数,是用来创建ID为repeater的控件实例:
1: [DebuggerNonUserCode]
2: private Repeater __BuildControlrepeater()
3: {
4: Repeater repeater = new Repeater();
5: base.repeater = repeater;
6: repeater.HeaderTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(this.__BuildControl__control4));
7: repeater.ItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(this.__BuildControl__control5));
8: repeater.FooterTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod (this.__BuildControl__control7));
9: repeater.ID = "repeater";
10: return repeater;
11: }
12:
13:
CompiledTempateBuilder和BuildTemplateMethod只是模板实例化的一个中介,真正用于添加模板内容 的是后面的那些私有函数,如ItemTempate的模板内容实例的创建就在__BuildControl__control5函数中 ,这个函数原型定义是:
1: [DebuggerNonUserCode]
2: private void __BuildControl__control5(Control __ctrl)
3: {
4: DataBoundLiteralControl control = this.__BuildControl__con
|