System.Web.UI.WebControls.GridView.DataBind Method

Binds the data source to the System.Web.UI.WebControls.GridView control. This method cannot be inherited.

Syntax

public override sealed void DataBind ()

Remarks

Use the GridView.DataBind method to bind data from a data source to the System.Web.UI.WebControls.GridView control. This method resolves all data-binding expressions in the active template of the control.

The GridView.DataBind method is called automatically if the DataBoundControl.DataSourceID property of the System.Web.UI.WebControls.GridView control refers to a valid data source control.

Instead of manually calling the GridView.DataBind method, you can use model binding with your GridView.DataBind control by setting the DataBoundControl.SelectMethod property to the name of a method that returns data for the System.Web.UI.WebControls.GridView. The System.Web.UI.WebControls.GridView is then automatically populated with the data that is returned from the select method. Model binding can simplify your code for working with data. For more information, see tp://go.microsoft.com/fwlink/?LinkId=286117.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0