One to many relationships on webforms

G

Guest

I am very new to .net and asp.net. I am trying to design an intranet page
that has a SQL Server 2000 database. I understand how to connect to the data
but am getting very confused on how to display, update and modify data in a
one to many relationship.

Is there any resource available that can show me how a web form looks when
the data is in a one to many relationship.

I've done work in MS Access and it was very easy using sub forms but I am
now lost trying to figure out how this should be done in ASP.NET using Visual
Studio 2003.

any help would be greatly appreciated. Thanks.
 
K

Kevin Spencer

A one-to-many relationship is a database relationship, which relates a
unique key column in one table to a foreign key column in another, in such a
way that there may be many records in the table with the foreign key that
relate to a single record in the table with the unique key.

That said, how one works with the data is determined largely by what one
wants to do with the data. One-to-many relationships have a number of uses,
and the development solution for each use is different.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 
G

Guest

Thanks for replying but I do understand what a one-to-many relationship is in
SQL. What I don't understand is how to display this in a web form. When I
create a form in MS Access it was very easy in that I drop a sub form on a
main form and link the keys. This is not possible in a web form. Let's say
for example I am creating a web form that is to display Patient information.
Each patient has a unique number that defines them but there is another
unique number that explains each time a patient visits a doctor. How would I
display the patient information on a web form but also display all the visits
also?
 
W

William Buchanan

You can use the new data aware components (Gridview, DetailsView, FormView)
in conjunction with the new TableAdapters, DataSets and DataSources
(ObjectDatasource, SQLDataSource).

It's a bit long winded, but basically you can get your master data in a
GridView, then use a DetailsView to act as the "Many" - you can link them us
so that when you select a record in the GridView, the details view shows the
detail records.

You can set your tableadapters up so that you can select and update the
records from within this.

Best bet is to looks for some tutorials or helpful sites on these components
(there are loads of them) - Microsoft has some really helpful videos which
you can download (i've lost the link so you'll have to search).

Will
 
K

Kevin Spencer

Hi Robert,

When I'm not sure about what is known and what is not, I tend to go over
what may already be known. In this case, it was an introduction to the
answer. What you are talking about is known as a "master-detail" view of
data, in which the child table is displayed, and when a record in the child
table is selected, the parent table record corresponding to that child table
is displayed in a separate view.

In addition, what you're talking about is custom programming. Will
Buchanan's remarks are on-target. The only way to do this is to build it
yourself, using ASP or ASP.Net.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 
K

Kevin Spencer

Oops, sorry, I forgot that I was currently on the ASP.Net newsgroup. Here's
a couple of references for you:

http://www.dotnetjohn.com/articles.aspx?articleid=14
http://www.c-sharpcorner.com/asp/Articles/MasterDetailDCHK.asp
http://aspnet.4guysfromrolla.com/articles/040203-1.aspx
http://www.codeproject.com/aspnet/masterdetailgrid.asp

Again, sorry about the confusion. I hope this gets you going!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer

Presuming that God is "only an idea" -
Ideas exist.
Therefore, God exists.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top