group dataset

G

Guest

I want to group my data being returned from my dataset, the dataset looks
like this:

<bmw></bmw>
<Lexus></Lexus>
<ChevyTahoe></Chevy>
<Mercedes></Mercedes>
<ToyotaFourRunner></Toyota>

If I get bmw, Lexus, or Mercedes returned i want to group them as 'Luxury'
and show them in my grid as that, If I get ChevyTahoe or ToyotaFourRunner
returned want to show them as 'SUV' and so on. how can I accomplish this? Is
this possible to do?
 
C

Cowboy \(Gregory A. Beamer\)

Create a lookup table (enumeration) that describes what different autos are.
Add a column to the DataTable in question that contains that information.
You can do this the easy way (when you create the dataset from your
database) or the hard way (adding to each row).
 
G

Guest

unfortunally, I have to do this via code, the DB person does not want to
create any new tables for lookup or anything else right now. So how the data
is coming is, well I'm stuck with it. So when I do this via code, how would
I?
 
C

Cowboy \(Gregory A. Beamer\)

Then, you will have to create the column, programatically on each row. As
the row go through, examine the data you need to examine to determine the
type and add the column with the row.

For the lookup table, you will create in the XSD and then fill from an XML
file that loads the type. One way to seed this, and learn more about
datasets at the same time, is create a small app to fill the rows with the
proper data and then save off. Or, you can keep the fill routine for the
"type table" that shows luxury, et al.


The downside is you will have an empty field when filled from the database,
if you want to fully strong type the dataset, as you have no way of creating
the data.

Option 2:
In the SQL Query or stored proc that pulls the data, add a case statement
that determines the type of automobile:

CASE automobile WHEN 'Chevy' THEN 'Standard'
ELSE WHEN 'Jaguar' THEN 'Luxury'
.... etc.
ELSE 'Compact' END As AutomobileType

You can use numbers and make a true type DataTable in your DataSet.

Hope this makes sense.
 
G

Guest

ok thanks, it makes some sense, but if I can see a code snippet I could get a
better understanding of it.
 

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

loop through dataset 4
adding totals in gridview rows 0
select listbox 1
group data in grid 3
dual drop downs 1
grid format question 1
text file format 1
add a new row with totals - gridview 5

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,211
Latest member
NelleWilde

Latest Threads

Top