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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display multiple records per row in a datagrid

Status
Not open for further replies.

meckeard

Programmer
Joined
Aug 17, 2001
Messages
619
Location
US
Is it possible to display multiple records per row in a datagrid?

I want to display 3 records per row and want to use a datagrid in order to take advantage of the built-in paging.

Thanks,
Mark
 
Is it possible to display multiple records per row in a datagrid?
Are these records related (e.g. Parent/Child records)?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

No. There is no relationship between the 2 sets of records.

Thanks.
 
So why do they need to be in the same row?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I am building a page that will display homes for sale. There must be 3 per row with an advertisement row between each home row. It's my clients wish.

I know I could do this classic ASP style and simply loop thru a datareader using response.writes, but I figured there must be a way to do this using a server control. At least I hope so.

Thanks.
 
OK - I can understand the request for an advertisment row and this would be fairly easy to implement, however, I don't see the need for having 3 rows within 1 row. Surely it woul be the same to have 3 rows (you could make them all look the same) and then have the advertisement row.

If they insist on having that then the only way(s) I can think of are:

1) Create some sort of Parent/Child relationship and then simply nest another datagrid (containing the 3 homes) within each row (the Alternating Row could then be the advertisement feature)

2) See if you could nest a repeater control within each row (I'm not sure how easy it would be without some sort of relationship though).

There may be other people who have other suggestions but that is all I can think of!


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

Just to clarify, there needs to be 3 homes per row, not 3 home rows per rows. We may be talking about the same thing tho.

I sort of think about this using a static HTML table. The first row would have 3 cells, each one containing an image of a home and the name. This would repeat 3 times and then, on every 4th row, the new table row would have only 1 cell with a colspan=3 displaying the advertisement.

I will google nested controls to see if there is something that I can use.

Thanks again for your imput.
 
OK - I was thinking that you wanted 3 rows incorporating into one row and then an advertisment.

This makes it much easier. What I would do is:

1) Read all your data in a DataTable
2) Create a new DataTable with 3 columns
3) Loop through the 1st DataTable adding a home to each of the 3 columns, then add an new row (for the advertisment) and then continue like this.

Let me know if this makes sense (and if you need any help with any of the code).

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

Let me start with a huge thanks! I really do appreciate the help.

OK, I think I understand it with a few exceptions.

Each "home" record consists of a path to an image, the community name, address, state & zip (5 fields). So how would I add each set of 5 fields to each column of the datatable? Would I simply make each column a varchar(1000) and then add all 5 fields?

Each "advertisement" record consists of a title and description. How could I add these 2 fields and make it span or fit across 3 fields in the datatable?

Let me know if I am viewing a datatable incorrectly. To me, if sort of seems like a table in a database or maybe an HTML table and the columns are headers. It's very possible that this is limiting my ability to conceptualize this.

Thanks,
Mark

Thanks,
Mark
 
As far as the database goes, you would simply add 5 fields to a "home" table (don't set them all to varchar(1000) though - set them accordingly to what they will contain). Then, have an "advertisment" table which has the two fields for the title and description.

Once this is set up we can go through the theory of how to implement it. If you have a go yourself using this logic then we will be able to help you with any specific problems you may have (and give you some examples).

Hope this helps.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

Sorry, I think I was unclear.

What I meant was how would I add the 3 home records from the database to the 3 columns in row of the datatable?

Let me know if I am not being clear enough. It would be the first time :)

Thanks,
Mark
 
You could add them as a string as you would like them formatted on the page e.g.
Code:
myRow = MyDataTable.NewRow
myRow.Item(0) = "<b>" & Column1 & "</b><br><img src=""" & Column2 & """><br>" & Column3
' Column1, 2 & 3 would be the columns from the first data table
MyDataTable.Rows.Add(myRow)


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
I also meant to mention that the free XRepeater control from einteract may come in useful as well:


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

I will look at XRepeater. Thanks!

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top