PC Review


Reply
Thread Tools Rate Thread

Databind using relationships

 
 
priyanka@radiotime.com
Guest
Posts: n/a
 
      5th Aug 2003
Hi All,

I am trying to display parent child records in two separate datagrids.
The 2 tables have the relationship set in the dataset. I bind the
datagrid using the relationship names, so that when a parent record is
selected in the first grid, the corresponding child records are
displayed in the second grid automatically.

I set the relationship in the dataset in a separate class and the
binding in another class. I am not able to get the second grid to
display child records automatically corresponding to the parent. I hav
pasted my code below. Any help would be great!

Thanks

Public Class GenreData
......
......
Public Function GetGenreFromSql()
'Add relationships between tables
genreDS.Relations.Add("genre2Stations",
GenreData.genreDS.Tables(GENRE_TBL).Columns("genre_no"),
_
GenreData.genreDS.Tables(STATION_TBL).Columns("genre_no"))

End function
end class

public class DataGridPopulator

public function BindGrid(byref tmpGrid as datagrid)
tmpGrid.SetDataBinding(GenreData.genreDS,
"genre_tbl.genre2Stations")
end function

end class
 
Reply With Quote
 
 
 
 
Rajeev Soni
Guest
Posts: n/a
 
      5th Aug 2003
Check this out

http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q780q

Rajeev

<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi All,
>
> I am trying to display parent child records in two separate datagrids.
> The 2 tables have the relationship set in the dataset. I bind the
> datagrid using the relationship names, so that when a parent record is
> selected in the first grid, the corresponding child records are
> displayed in the second grid automatically.
>
> I set the relationship in the dataset in a separate class and the
> binding in another class. I am not able to get the second grid to
> display child records automatically corresponding to the parent. I hav
> pasted my code below. Any help would be great!
>
> Thanks
>
> Public Class GenreData
> .....
> .....
> Public Function GetGenreFromSql()
> 'Add relationships between tables
> genreDS.Relations.Add("genre2Stations",
> GenreData.genreDS.Tables(GENRE_TBL).Columns("genre_no"),
> _
> GenreData.genreDS.Tables(STATION_TBL).Columns("genre_no"))
>
> End function
> end class
>
> public class DataGridPopulator
>
> public function BindGrid(byref tmpGrid as datagrid)
> tmpGrid.SetDataBinding(GenreData.genreDS,
> "genre_tbl.genre2Stations")
> end function
>
> end class

 
Reply With Quote
 
priyanka@radiotime.com
Guest
Posts: n/a
 
      5th Aug 2003
Hi,

The Master - child grid doesnt work if the first grid is a view as in
my case. I hav the parent grid as a view since there are too many
records to be displayed.

Is there a way to make the parent child relationship work with the
view.

Priyanka
 
Reply With Quote
 
Gregory Persson
Guest
Posts: n/a
 
      5th Aug 2003
In the case of binding to a DataView, you are binding to a Table, not a
DataSet. Therefore, there is no relationship in the DataObject being bound
to your Master Table. No relationship = no Master-Detail form. In this case,
you'll want to bind to a DataViewManager, which is basically a DataView for
a DataSet. Here's the proper way to bind:

dataGrid1.SetDataBinding( dataSet1.DefaultViewManager, "Table1" );
dataGrid2.SetDataBinding( dataSet1.DefaultViewManager, "Table1.Relation1" );

I would read http://www.oreilly.com/catalog/adone...apter/ch12.pdf for
further information about Binding and DataViewManagers. Also, consult MSDN
to find out how to use the DataViewManager to access the DataView for the
Master Table.

~Greg Persson
MCP


 
Reply With Quote
 
priyanka@radiotime.com
Guest
Posts: n/a
 
      6th Aug 2003
Thanks Greg, I will read up on that
Priyanka
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Databind ?? Adam J Knight Microsoft ASP .NET 2 1st Feb 2006 11:10 PM
Databind # ? ad Microsoft ASP .NET 2 22nd Jul 2005 11:18 PM
DataBind Rafael Metring Microsoft Dot NET Compact Framework 1 27th Feb 2004 07:54 PM
Databind Steven Licciardi Microsoft Dot NET Compact Framework 2 24th Feb 2004 07:43 PM
relationships disappearing in relationships view Em Bond Microsoft Access 1 25th Jul 2003 06:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:05 PM.