Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should you use Page.DataBind() versus Control.DataBind()?

Tags:

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?

like image 490
Jason Berkan Avatar asked Oct 21 '09 20:10

Jason Berkan


People also ask

What does Page DataBind do?

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.

What is the use of DataBind method of GridView control?

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.

What is DataBind in Ado net?

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).


1 Answers

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.

like image 161
John Saunders Avatar answered Sep 22 '22 03:09

John Saunders