Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Binding a GridView to a particular table in an ObjectDataSource

Reply
Thread Tools

Binding a GridView to a particular table in an ObjectDataSource

 
 
Jeronimo Bertran
Guest
Posts: n/a
 
      04-04-2006
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
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      04-04-2006
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.)

 
Reply With Quote
 
 
 
 
Jeronimo Bertran
Guest
Posts: n/a
 
      04-04-2006
Thanks Steven.
 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      04-05-2006
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.)

 
Reply With Quote
 
justengland@gmail.com
Guest
Posts: n/a
 
      04-11-2006
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

 
Reply With Quote
 
justengland@gmail.com
Guest
Posts: n/a
 
      04-11-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Binding in GridView when using ObjectDataSource SteveM ASP .Net Web Controls 1 04-03-2009 09:57 AM
GridView - ObjectDataSource - Data Binding =?Utf-8?B?UGhpbGlw?= ASP .Net 2 10-24-2006 03:00 PM
GridView binding - how to stop initial binding Amit ASP .Net 6 10-24-2006 08:06 AM
Binding tables interesection with GridView/ObjectDataSource [newbie] H5N1 ASP .Net 0 03-27-2006 03:34 AM
Binding tables interesection with GridView/ObjectDataSource [newbie] H5N1 ASP .Net Datagrid Control 0 03-27-2006 03:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57