0

I wonder if there is any difference between two parts of code:

   //1
    public partial class MyPage : System.Web.UI.Page
    {

     public override void DataBind()
     {
        base.DataBind();
        this.myTableGrid.SetupDataSource();
     }

    }

    //2
    public partial class MyPage : System.Web.UI.Page
    {

     public void Page_DataBind(object e, EventArgs e)
     {
        this.myTableGrid.SetupDataSource();
     }

    }
Alexandre
  • 13,030
  • 35
  • 114
  • 173

1 Answers1

0

Essentially, they both accomplish the same task. Your Page_DataBind method will be called in base.DataBind() so it might save a teeny tiny (i.e. negligible) amount of cpu clicks as it doesn't have to call the method delegate.

One difference in example 2 is that you can call that method, without having to call DataBind() on the page.

This may prove useful if have a lot of controls on your page but only want to databind a few of them (as databinding can prove to be a costly operation, given that it makes heavy use of reflection and type casts).

leon.io
  • 2,779
  • 1
  • 18
  • 26