Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Gridview. Fill dataset with various tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 17 Sep 2007 14:31 GMT
Hello,

I have 2 SQL tables as follows:

[Articles] > ArticleId (PK), Title, Body
[Categories] > CategoryId (PK), ArticleId (FK), CategoryName

Basically I want to display a GridView with the articles.
Then for each article I want to have child gridview with the comments.

I suppose I need to have a dataset with 2 tables, one for Articles and
other for comments.

How can I create this in ASP.NET 2.0?
And how should my SQL 2005 Stored Procedure return the data?

Thank You,
Miguel
Just Me - 19 Sep 2007 09:17 GMT
On the command event for the "Articles" GridView, you can trap the selected
row of the parent grid. You can then get the PK and  query the server for
the specific comments for that article and bind the table to the child
grivew

As far as the Stored Procedure is concerned, Table adapters make life so
much easier, tbh, its much easier to use them that to fart around with
stored procs unless performance is a grinding issue or procedures demand it.

In order to do that simple drag the required table to a dataset and then you
can add queries with parameters into the table adapter, this then can be
called from the table adaptes namespace for that dataset for example.

Dim ArticlesTableAdapter as  new
MyDataSetTablerAdapters.ArticlesTableAdapter
Dim ArticleComments as MyDataSet.ArticleCommentsTable
ArticleComments = ArticlesTableAdapter.getCommentsByArticleID( ArticleID )

ChildGrid.DataSource=ArticleComments
ChildGrid.DataBind

--

Voila, job done.

> Hello,
>
[quoted text clipped - 14 lines]
> Thank You,
> Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.