Datagrid/Datalist - Multiple Rows as one questions.

M

Mike

Hi!
Been stuck on this one for a bit. Would really appreciate any help on
this one.

To start. I have a sql database table with the following data and
design (ex)

------------------------------------
provider_id | plan_id | plan cost
------------------------------------
1 US-1 20.00
1 US-2 30.00
1 US-3 40.00
2 UK-1 10.00
2 UK-2 20.00
2 UK-3 32.00

I need to display this in a way (DataGrid, DataList, etc...)
where I can view all provider items on the same, line and select a
plan
using a radiobuttonlist or similar.

I'm not sure if it is something I need to do in the database query or
something
at the application level.

It will need to look something like this:

------------------------------------------
provider_id | plan_1 | plan_2 | plan 3
------------------------------------------
1 20.00 30.00 40.00
2 10.00 20.00 32.00

I would like the to be able to select a dollar amount(by radiobutton
if possible) and have the plan_id as the value if possible.

Has anybody got something like this working.
 
C

cbDevelopment

There are quite a few ways to accomplish this. This is one potential
solution. First off, some observations and assumptions.

You are titling your result table with a string that is not included in
your schema. I assume this will be a label like "Plan " & x, which x is an
incrementing number. I also assume you are dealing with the same number of
plans for each provider, although this would become an issue later if the
providers offer differing numbers of plans.

I do not know if you need to select one plan per provider or one plan among
all providers.

So, one way to accomplish this is to have a repeater control loop through a
distinct list of provider IDs. I will assume this is in a table and
providerID is the primary key.
Within each Repeater item template, use a radio button list with horizontal
orientation to display the plas for the current provider ID. This can be
done by bringing in all the plans and using a dataview to filter the plans
by provider ID and bind to the list.

Here's some psudeoCode:
(dt=datatable, dac=Data access component [you do have a data access layer,
right?], rpt=repeater, rbl=radiobuttonlist, dv=dataview)

' Get providers
dtProviders=dacProvider.Getproviders()

' get plans
dtPlans=dacPlans.GetAllPlans()

' Bind Providers to Repeater
with rptProviders
.datasource=dtproviders
.databind
end with

' in Handler for rptProviders.ItemDataBound
' Get the radiobuttonlist in the repeater Item template
rblPlans=ctype(e.item.findcontrol("rblPlans"),radiobuttonlist)

' Filter the plans datatable by the current Provider ID
with dvPlans
.table=dtplans
.rowfilter="provider_id=" & _
ctype(e.item.dataitem,datarowview).item("ID")
end with

' bind the filtered list
with rblPlans
.datasource=dvPlans
.databind
end with

You will have to tweak some of the settings as you go, but I think this
will get you started in the right direction. If not, there's always the
crosstab technique. That can be done in a SQL Stored Procedure using
dynamic SQL.

Best of luck!

(e-mail address removed) (Mike) wrote in @posting.google.com:
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top