Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable auto data bind of ASP.NET page?

How can I prevent ASP.NET page from automatically binding data controls on the page? I want to increase performance and I want to do binding of each data control based on my own order.

like image 749
Afshar Mohebi Avatar asked Dec 06 '10 12:12

Afshar Mohebi


2 Answers

Simple, don't setup data binding on the controls in the designer.

You would then have to bind the controls inside the code behind part of the page with code.

like image 78
Tony Abrams Avatar answered Oct 07 '22 14:10

Tony Abrams


Not quite what the OP asked for but it is also possible to cancel the Select operation on the Datasource control by adding an event handler to the Selecting event.

public void DataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
    if (CancelSelect())
    {
        e.Cancel=true;
        return;
    }
}
like image 25
Stuart Avatar answered Oct 07 '22 13:10

Stuart