Binding a GridView to a particular table in an ObjectDataSource

Discussion in 'ASP .Net Datagrid Control' started by Jeronimo Bertran, Apr 4, 2006.

  1. Hello,

    I am using a ObjectDataSoruce which populates a dataset with 2 tables.


    I then bind a GridView using the DataSourceID property set to the
    ObjectDataSource. However, I need to use a particular table in the
    resulting dataset. If I set the DataMember property in the GridView I get
    an exception because the ObjectDataSource only supports a single view.

    Is there any way to bind to the second table of a dataset returned by
    OjectDataSource?

    Thanks

    Jeronimo
     
    Jeronimo Bertran, Apr 4, 2006
    #1
    1. Advertising

  2. Hi Jeronimo,

    Welcome to the ASPNET newsgroup.

    From your description, I understand you have an ASP.NET 2.0 web page which
    contains a GridView control displaying data from an ObjectDataSource
    control. And the objectdatasource control's associated data access class
    will return a DataSet which contains two datatables, you're wondering how
    to make the gridView be able to bound to a specific datatable in the
    DataSet rather than always hte default one, correct?

    Based on my understanding, if we directly return a DataSet for data access
    class(used in objectDataSource control), it will always return the
    DefaultView of the default datatable(basically the first one). So what we
    need to do is customize the Data Access class(which provide the select,
    update .... methods). Is this class also developed by you or can you
    directly modify it? If not, you may consider create a wrapper class which
    encapsulate it.

    In our customized class, we can add an additional parameter for the Select
    method, this parameter is used to indicate which datatable to return. Then,
    when bound to GridView and used in ObjectDataSource control, we just need
    to define an additional paramters (control parameter or querystring or
    ....). How do you think of this?

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Apr 4, 2006
    #2
    1. Advertising

  3. Thanks Steven.
     
    Jeronimo Bertran, Apr 4, 2006
    #3
  4. You're welcome Jeronimo,

    Regards,

    Steven Cheng
    Microsoft Online Community Support


    ==================================================

    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.



    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Apr 5, 2006
    #4
  5. Jeronimo Bertran

    Guest

    if you get the default view exception. And you are doing the
    ObjectBinding make sure that you do not have the datamember property
    set on the Gridview. Having it will cause it to look for a datamember
    within your result.

    Hope this helps
    Justin
     
    , Apr 12, 2006
    #5
  6. Jeronimo Bertran

    Guest

    if you get the default view exception. And you are doing the
    ObjectBinding make sure that you do not have the datamember property
    set on the Gridview. Having it will cause it to look for a datamember
    within your result.

    Hope this helps
    Justin
     
    , Apr 12, 2006
    #6
    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. H5N1
    Replies:
    0
    Views:
    479
  2. Amit
    Replies:
    6
    Views:
    13,808
    Assimalyst
    Oct 24, 2006
  3. =?Utf-8?B?UGhpbGlw?=

    GridView - ObjectDataSource - Data Binding

    =?Utf-8?B?UGhpbGlw?=, Oct 24, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,010
    =?Utf-8?B?UGhpbGlw?=
    Oct 24, 2006
  4. H5N1
    Replies:
    0
    Views:
    145
  5. SteveM

    Data Binding in GridView when using ObjectDataSource

    SteveM, Apr 1, 2009, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,042
    Ladislav Mrnka
    Apr 3, 2009
Loading...

Share This Page