Databinding: Web Forms vs. Windows Forms

In Windows Forms, all data binding done by the designer is saved as code in the choosen language: C# or VB.NET:



// dataGrid1


this.dataGrid1.DataMember = "Customers";

this.dataGrid1.DataSource = this.dataSet11;


On Web Forms, it’s somewhat different, because when binding a DataGrid to a DataTable via designer, the binding isn’t saved as code; instead it’s saved as markup:


<asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" runat="server" DataSource="<%# dataSet11 %>" DataKeyField="CustomerID" DataMember="Customers" AutoGenerateColumns="False" EnableViewState="False">

      // Column definition



Leave a Reply