When should I use simple binding vs complex binding?
Use simple binding for one value in a single control. Use complex binding for lists and grids where multiple rows are shown.
Data binding links values from a data source to UI controls so users can see and edit data. In ASP.NET Web Forms you use two common styles: simple binding for a single value, and complex binding for lists and tables.
Simple binding connects one value to a control such as a Label or TextBox. You can bind at design time with expressions or at runtime by setting properties and calling DataBind.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) DataBind();
}
Complex binding connects a list of rows to controls like ListBox, DropDownList, GridView, or Repeater. You set the data source (for example a DataTable or a LINQ query), choose the text/value fields, and call DataBind to render.
// Data source: a list or DataTable
List data = GetCategories();
ListBox1.DataSource = data;
ListBox1.DataTextField = "Name";
ListBox1.DataValueField = "Id";
ListBox1.DataBind();
<%# (bool)Eval("Active") ? "Yes" : "No" %>
// Code-behind
GridView1.DataSource = GetCategories();
GridView1.DataBind();
When you add bindings in Visual Studio, the .aspx markup gets data binding expressions. At runtime ASP.NET evaluates those expressions when DataBind runs and places values into controls. In older Windows Forms apps a CurrencyManager tracked the current record; in Web Forms the page rebinding cycle uses DataSource controls or your code to provide the current data.
// After you change data, refresh the bound controls
SaveChanges();
Page.DataBind(); // or GridView1.DataBind();
Keep bindings readable. Prefer field names that make sense, and avoid heavy logic in the markup. For lists, set DataTextField and DataValueField. For templates, use Eval or Bind as needed.
Use simple binding for one value in a single control. Use complex binding for lists and grids where multiple rows are shown.
Update the data source, then call DataBind on the control or the whole Page to evaluate binding expressions again.