Gridview. Fill dataset with various tables

S

shapper

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
 
J

Just Me

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

GridView, DataSet 1
Fill GridView 1
Fill Dataset with two tables 6
DataSet 2
Gridview and dataset with multiple tables 0
DataSet to Generic List 1
Dataset - Get Values 4
Fill method for Dataset 3

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top