Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get a datagrid with 2 sets of columns?

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
Okay, here is what I want in my data grid:
Col1 Col2 Col3 |Col1 Col2 Col3
rec1 data data |rec4 data data
rec2 data data |rec6 data data
rec3 data data |rec7 data data


Can I do this? If so how?
 
hmmm...never done that before, but if you get a dataset that has two datatables in it, and you specify the first three columns to bind to fields in datatable1 and the last three columns to bind to fields in datatable2, maybe that would work?

Or, do they *have* to be in the same datagrid? You could just have two datagrids.

D'Arcy
 
It's data from one table. I could do something like that, hmmm... I'd have to load the first half of the table into one datatable and the second half into the other.
 
but qwert...if its data from one table, why not just tamper with the column border between columns 3 and 4?

D
 
Instead of rec 1 thru 10 flowing one after another, I want 1 - 5, then 6 - 10. Note, in my example, I only have col1,2,and 3. But they show up twice.
 
ah, now I understand. Interesting problem...

well, you could (just grabbing this out of the air) add a second datagrid, and if the records are greater than a certain number have your code make it visible and bind it to the remaining items in your dataset/datatable.

Does it have to be in a datagrid? Is it possible to do it in a different sort of interface (i.e. dynamically generated table where the rows and columns are created programmatically?

D
 
>dynamically generated table
Yeck! That's how I did it in ASP Classic. I thought we could come up with something cleaner and more efficient.

Plus, they have to have textboxes in the first column, so the person can enter a quantity, and the 3rd column shows the price.

So:
column1 = quant
column2 = label
column3 = price (quant * priceOfItem)

I'm working out the 2 datagrid problem.
 
K, so here's the latest. I have a Stored Procedure (ah hah! He can be taught!) that returns all my items. I then want to have half go to one datagrid, and half to another. Can I do this with a view? Or should I have 2 stored procedures. (To make this easy, I will always use the 2 datagrids.)
So it'll be.
1 5
2 6
3 7
4 8
 
K, here's what I got, and it seems to work. I added a field called Sequence. It's a number field, so I can get the count of records and divide by 2 (with some rounding and adding one to the result)
So then I do 2 views.
Sequence < math.ceiling(recs/2) + 1
Sequence > math.ceiling(recs/2)

It'll be tricky. The stored procedure is grouping the results... so the table looks like this:
GroupID, Sequence, Package, Code
1, 1, 1, X800
1, 1, 1, X802
1, 2, 2, X803
1, 2, 2, X800
1, 3, A, X801
1, 4, B, X800

Yeck.
 
Sorry, that last listing is the original table. The stored procedure groups by package. (I don't need the code in these results so I drop that field. I query by Program)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top