0

I am facing a problem . I have a Parent Form . Where i am creating 20 Datatable that is using to bind the combobox for child form. So i want that i create a public function .I want to pass the datatable that is created on my Parent form i can use on child form as ref . So how can i do that . Present i am using this code but every time when child form every time its fire my parent page function. What i am doing wrong, What will be the best approach to do this.

I also take a reference form my previous Question and convert my dataset to LIST Type but the load time of form not decrease.

Parent Form

  public DataTable _tableZip (ref  DataTable zip)
    {
         if (_forderdac == null)
             _forderdac = new foOrderDAC();
             DataTable _tblZip = new DataTable();
            _tblZip = _forderdac.GetZipPostal(appDirectory, this.FindForm().Name, "frmCometFastOrderEntry").Tables[0];

        return _tblZip;
    }

Child form

            DataTable _tableZip = new DataTable();
            cmblookupPickZip.DataSource = _frmcometfast._tableZip(ref _tableZip);

            if (_tableZip.Rows.Count > 0)
            {
                cmblookupDropZip.DisplayMember = "ZIPPOSTAL";
                cmblookupPickZip.ValueMember = "AREAID";
                cmblookupPickZip.SelectedIndex = -1;
            }

thanks for your comments .

Community
  • 1
  • 1
A.Goutam
  • 3,422
  • 9
  • 42
  • 90
  • 2
    "I want to pass the datatable that is created on my Parent form i can use on child form as ref." - are you *sure* that's what you want to do? Are you sure you understand what `ref` does? – Ant P Jan 09 '15 at 12:30
  • @PatrickHofman please take a look i have made changes in my post and add my previous reference – A.Goutam Jan 09 '15 at 12:42
  • Do not create `Table` inside `Form`. Create [business layer](http://en.wikipedia.org/wiki/Multilayered_architecture) which will hold all your data and related properties, and will be performing all operations with database (add, remove, update, etc). Parent and child form have to use that layer to populate their view. – Sinatr Jan 09 '15 at 13:01

0 Answers0