473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Displaying a 1-many relationship properly

Hi!

I just run into a problem wich some of you might be able to solve
really quickly so i decided to give this group a shot.

In the database a have 2 tables (well, to make it easy here).
1) Question
2) Answer

Each question has multiple answers attached to it. this means that
your will get the following result set.
---------------------------
quesion1 (type 1) -- answer1q1
quesion1 (type 1) -- answer2q1
quesion1 (type 1) -- answer3q1

quesion2 (type 1) -- answer1q2
quesion2 (type 1) -- answer2q2

quesion3 (type 2) -- answer1q3
quesion3 (type 2) -- answer2q3
quesion3 (type 2) -- answer3q3
quesion3 (type 2) -- answer4q3
---------------------------

Now each question has also a 'type'.

The problem:

I would like to display the question,if type 1, in a single line with
behind it a select box with all the answers in it. So display the
question once and put the answers to that question in a selectbox.

I have no idea how many questions or how many answers each question
has...

anyone any idea's ??
Nov 18 '05 #1
3 1097
As far as I know there's no magical way for the UI(ASP.NET) to recognize that you hava hierarchical dataset

Now your Answers table should have a foreign key column from the questions table that tells you which answers belong to which questions

So get two datatables 1 for your questions and 1 for you answers

From the questions table display the questions(choose your own way to display this i.e. HTMLTable or DataList) Then following each question create a dropdownlist dynamically and populate the answers into it based on which question you are on

HTH
Suresh
----- Frank wrote: ----

Hi

I just run into a problem wich some of you might be able to solv
really quickly so i decided to give this group a shot

In the database a have 2 tables (well, to make it easy here).
1) Questio
2) Answe

Each question has multiple answers attached to it. this means tha
your will get the following result set
--------------------------
quesion1 (type 1) -- answer1q
quesion1 (type 1) -- answer2q
quesion1 (type 1) -- answer3q

quesion2 (type 1) -- answer1q
quesion2 (type 1) -- answer2q

quesion3 (type 2) -- answer1q
quesion3 (type 2) -- answer2q
quesion3 (type 2) -- answer3q
quesion3 (type 2) -- answer4q
--------------------------

Now each question has also a 'type'

The problem

I would like to display the question,if type 1, in a single line wit
behind it a select box with all the answers in it. So display th
question once and put the answers to that question in a selectbox

I have no idea how many questions or how many answers each questio
has..

anyone any idea's ?

Nov 18 '05 #2
Hi,

just create two datasets and bind them to a listbox, datagrid or some
otherview.
In the first dataset, you load all your questions. On selection changes in
the question grid,
you just update the SELECT statement of the second dataset (the answers). I
guess you
linked the answers to the questions through some primary/foreign keys ?
That's the global scenario.

Greetings,

Bram

"Frank" <fr***@hubhop.com> wrote in message
news:6c**************************@posting.google.c om...
Hi!

I just run into a problem wich some of you might be able to solve
really quickly so i decided to give this group a shot.

In the database a have 2 tables (well, to make it easy here).
1) Question
2) Answer

Each question has multiple answers attached to it. this means that
your will get the following result set.
---------------------------
quesion1 (type 1) -- answer1q1
quesion1 (type 1) -- answer2q1
quesion1 (type 1) -- answer3q1

quesion2 (type 1) -- answer1q2
quesion2 (type 1) -- answer2q2

quesion3 (type 2) -- answer1q3
quesion3 (type 2) -- answer2q3
quesion3 (type 2) -- answer3q3
quesion3 (type 2) -- answer4q3
---------------------------

Now each question has also a 'type'.

The problem:

I would like to display the question,if type 1, in a single line with
behind it a select box with all the answers in it. So display the
question once and put the answers to that question in a selectbox.

I have no idea how many questions or how many answers each question
has...

anyone any idea's ??

Nov 18 '05 #3
"Bram" <bv*****@nospam.skynet.be> schreef in bericht
news:40*********************@news.skynet.be...
just create two datasets and bind them to a listbox, datagrid or some
otherview.
In the first dataset, you load all your questions. On selection changes in the question grid,
you just update the SELECT statement of the second dataset (the answers). I guess you
linked the answers to the questions through some primary/foreign keys ?
That's the global scenario.


That is also the reason why many database frontends are slow, programming
isn't just attaching a recordset to a grid/listcontrol.

You can use just one dataset and when loading the questions (primary key
data) store the rowindex (or bookmark) of each first row from the primary
key (some grids have a rowdata or rowtag property, a invisible column can
be used too).

When a user selects a row of the questions list, move to the stored row
(from the index/bookmark you stored) and update the second control (movenext
till the primary key changes or EOF reached).

This gives you a faster GUI reducing server balast and network I/O.

Rene
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Waguih Boctor | last post by:
Hi, I have a number of ASP pages where some JPGs and GIFs are displaying in the browser and some are not. I have included an excerpt from the HTML below. In this example, the gif file at the...
8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
1
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time...
2
by: Joe Price | last post by:
Hi chaps I've got an XML file, within that file i've embedded html code using the <!]> tag I'm displaying that xml file through a browser using an xsl style sheet. However it is displaying...
1
by: Yoshitha | last post by:
hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd...
2
by: Carole MacDonald | last post by:
There have been lots of posts on this topic, but I haven't been able to apply any of the suggestions to my situation. I have an .aspx page with a form on it that has several submit buttons on...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
0
by: dipper | last post by:
I have a dataset with several tables. Now i want to create different dataviews displaying results from some of the tables. I manage to create a view displaying 1 table, but how do i create a view...
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.