gridview, objectdatasource

Discussion in 'ASP .Net' started by family, Dec 22, 2005.

  1. family

    family Guest

    I have few classes in my business layer like:

    Country:
    CountryId (int)
    CountryName (string)

    CountryManager:
    GetAllCountry
    AddCountry
    RemoveCountry
    UpdateCountry

    State:
    StateId (int)
    StateName (string)
    StateCountry (country)

    StateManager:
    GetAllState
    AddState
    RemoveState
    UpdateState


    I am using a Gridview control to maintain list the states on AdminState
    page. There are template fields for the StateName and CountryId
    columns.

    I have an ObjectDataSource defined as:

    <asp:ObjectDataSource ID="StateDataSource" runat="server"
    TypeName="MyBusinessLayer.StateManager"
    DataObjectTypeName="MyBusinessLayer.State"
    SelectMethod="GetAllState"
    DeleteMethod="RemoveState"
    UpdateMethod="UpdateState" >
    </asp:ObjectDataSource>

    Since the CountryId property is not defined on the State object,
    gridview throws the error:

    DataBinding: 'MyBusinessLayer.State' does not contain a property with
    the name 'CountryId'

    How can I bind the controls in the gridview template columns to
    properties in my business object that point to other business objects?

    Thanks in advance!
    family, Dec 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kha Tran
    Replies:
    0
    Views:
    540
    Kha Tran
    Jun 3, 2005
  2. Danny W

    GridView update with ObjectDataSource

    Danny W, Sep 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,059
    Danny W
    Sep 8, 2005
  3. =?Utf-8?B?Sm9obl9I?=
    Replies:
    1
    Views:
    2,758
    =?Utf-8?B?Sm9obl9I?=
    Jan 19, 2006
  4. =?Utf-8?B?Y2dzaA==?=
    Replies:
    0
    Views:
    1,145
    =?Utf-8?B?Y2dzaA==?=
    Jan 8, 2006
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    228
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page