How to pass a Datatable from one class A to another Class B

Mar 12 2014 7:12 AM
hi all..

I'm trying pass a DataTable from Class A to Class B [Here I'm using 3-Tier architecture class b is in class library] using properties my code goes like this.

1)public  DataTable TYPE_TYRE()

In the above method(1) I'm using to bind the grid to DataTable  (working fine)

2)  protected void Test_Click(object sender, EventArgs e)

  Vehicle_Bal ObjB = new Vehicle_Bal();
  ObjB.DtTyre = TYPE_TYRE();


In (2) Button Click I'm Calling (1) assigning it to property from Class A to Class B everything is working fine[Case1 when testing] i could get data in to DataTable property in Vehicle_Bal i.e, class B

##But the problem is occurs when My code is like this in my method. 

3)  public void CreateVehicle()
  Vehicle_Bal ObjB = new Vehicle_Bal();

  ObjB .PurchaseDt = Convert.ToDateTime(txtPurchaseDate.Text);
  ObjB .WarrentyDt = Convert.ToDateTime(txtWarrentyDate.Text);
  ObjB .MIsc = txtMisc.Text;
  ObjB .VStatus = ddlVStatus.SelectedItem.Text;
  (*)ObjB .DtTyre = TYPE_TYRE();-----------(1)
4)----ObjB .BlCreateVeh();
5) )  protected void btnsave_Click(object sender, EventArgs e)

In case2 to Upto (*) its is working good, when Im calling  (4) i.e method from Class B and Passing the DataTable to Class B I'm not getting any Data

Please any one find out the problem and give me  solution to it.

Answers (2)