Retrieve Parent object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • benoit

    Retrieve Parent object

    Hi,

    I have this (newbie) question, and worse I am not quite sure how to ask it.

    My problem is a bit similar as this
    With DataTables and Row, one can perfectly write this code, and it makes
    some sense.

    DataTable myTable = new DataTable("new Table");
    DataRow vRow = myTable.NewRow( );
    myTable.Rows.Ad d(vRow);
    Response.Write( vRow.Table.Tabl eName);

    In my Classes I would like to implement a similar thing.

    namespace Engine{

    public class Offer{
    public Offer(){}
    //some more code
    public string OfferID{
    get{}
    set{}
    }
    }

    public class Program{
    public Program( string OfferID ){}

    }
    }

    So how can I from the class Program, retrieve the parent Offer?

    thx
    Benoit




  • Jianwei Sun

    #2
    Re: Retrieve Parent object

    benoit wrote:
    Hi,
    >
    I have this (newbie) question, and worse I am not quite sure how to ask it.
    >
    My problem is a bit similar as this
    With DataTables and Row, one can perfectly write this code, and it makes
    some sense.
    >
    DataTable myTable = new DataTable("new Table");
    DataRow vRow = myTable.NewRow( );
    myTable.Rows.Ad d(vRow);
    Response.Write( vRow.Table.Tabl eName);
    >
    In my Classes I would like to implement a similar thing.
    >
    namespace Engine{
    >
    public class Offer{
    public Offer(){}
    //some more code
    public string OfferID{
    get{}
    set{}
    }
    }
    >
    public class Program{
    public Program( string OfferID ){}
    >
    }
    }
    >
    So how can I from the class Program, retrieve the parent Offer?
    >
    thx
    Benoit
    >
    >
    >
    >
    You can pass Offer as an argument in the constructor, something like this:

    public class Program
    {
    private Offer _offer;
    public Program(Offer offer)
    {
    _offer =offer;
    }
    }

    Then , you can access that object in your program.

    Comment

    • benoit

      #3
      Re: Retrieve Parent object

      thx
      very much newbie question it was...

      "Jianwei Sun" wrote:
      benoit wrote:
      Hi,

      I have this (newbie) question, and worse I am not quite sure how to ask it.

      My problem is a bit similar as this
      With DataTables and Row, one can perfectly write this code, and it makes
      some sense.

      DataTable myTable = new DataTable("new Table");
      DataRow vRow = myTable.NewRow( );
      myTable.Rows.Ad d(vRow);
      Response.Write( vRow.Table.Tabl eName);

      In my Classes I would like to implement a similar thing.

      namespace Engine{

      public class Offer{
      public Offer(){}
      //some more code
      public string OfferID{
      get{}
      set{}
      }
      }

      public class Program{
      public Program( string OfferID ){}

      }
      }

      So how can I from the class Program, retrieve the parent Offer?

      thx
      Benoit


      >
      You can pass Offer as an argument in the constructor, something like this:
      >
      public class Program
      {
      private Offer _offer;
      public Program(Offer offer)
      {
      _offer =offer;
      }
      }
      >
      Then , you can access that object in your program.
      >

      Comment

      Working...