ASP.net 2.0 Data Binding Internals
Tuesday, 29 May 2007
Alexander Jung has a post outlining how ASP.net 2.0 data binding is implemented using code generation. A more detailed look at ASP.net 2.0 databinding internals is available at DotNetDan. Looking at the generated code, it surprised me that the Bind() method doesn’t even appear in the final generated code. Makes one wish that the ASP.net team had talked to the WinForms team, and used TypeConverters instead.
public IOrderedDictionary @__ExtractValues__control12(Control @__container) {
OrderedDictionary @__table;
TextBox TextBox2;
TextBox2 = ((TextBox)(@__container.FindControl("TextBox2")));
[…] // other controls ommited
@__table = new OrderedDictionary();
if ((TextBox2 != null)) {
@__table["id"] = TextBox2.Text;
}
[…] // other values ommited
return @__table;
}
Useful references on Asp.net Controls:
- Custom asp.net control with CSS and Postbacks
- Custom asp.net templated databound control
- MSDN – building databound controls (example doesn’t support the Bind or Eval syntax)
You should follow me on twitter here