In ASP.NET, you can bind controls individually (i.e. GridView1.DataBind()
) or you can call Page.DataBind()
to bind all controls on the page.
Is there any specific difference between the two calls? Are there times when one should be preferred over the other?
In ASP.NET, you can bind controls individually (i.e. GridView1. DataBind() ) or you can call Page. DataBind() to bind all controls on the page.
Use the DataBind() method to bind data from a data source to the GridView control. This method resolves all data-binding expressions in the active template of the control. The DataBind method is called automatically if the DataSourceID property of the GridView control refers to a valid data source control.
When you only need to have a control display a single value, like that of a TextBox control, this limited usage is referred to as "simple data binding." Simple data binding is the ability to bind a control to a single data element (such as a value in a column in a DataSet table).
Page.DataBind
is Control.DataBind
. Neither the Page
class, nor the TemplateControl
class overrides Control.DataBind
.
Control.DataBind
does little more than call OnDataBinding
for the control, then it calls DataBind
for each child control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With