请教,我重载了 DataBind() ,可为什么在调用它时,我用断点,根本没有执行
DataBind()它?请问这是什么原因?如果不重栽,我直接写在事件里就没事。
 public override void DataBind()
  {
   Staff st=new Staff();
   this.DataGrid1.DataSource=st.GetStaffInfo(this.StaffName.Text);
   this.DataGrid1.DataBind();
  }  private void Button1_Click(object sender, System.EventArgs e)
  {
//   Staff st=new Staff();
//   this.DataGrid1.DataSource=st.GetStaffInfo(this.StaffName.Text);
//   this.DataGrid1.DataBind();
   this.DataGrid1.DataBind();
  }
-- 

解决方案 »

  1.   

    你这个 public override void DataBind()
      {
       Staff st=new Staff();
       this.DataGrid1.DataSource=st.GetStaffInfo(this.StaffName.Text);
       this.DataGrid1.DataBind();
      }写到哪里去了,应该写到datagrid的派生类中,然后再生成一个这个派生类的对象,这个对象的DataBind();才是你自己的。
    你可以这样实现的
      private void Button1_Click(object sender, System.EventArgs e)
      {
    //   Staff st=new Staff();
    //   this.DataGrid1.DataSource=st.GetStaffInfo(this.StaffName.Text);
    //   this.DataGrid1.DataBind();
       this.DataBind();
      }