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

Datagrid - alternating row layout

Status
Not open for further replies.

th3maw

Programmer
Feb 16, 2005
26
0
0
GB
Hi

I would like to use a datagrid, as I would like to use the paging features and so on, however I am unsure how/if I can set the column values or the layout differently in each row.

Basically I want to flip each record...

...so record 1 would be

Image > Title > Description

.....and record 2 would be...

Description > Tile > Image

The columns will be a fairly uniform size.

I have found plenty of ways to change the colour of the row, or simply hide/delete the value of columns, but I can't figure out what code I need to use to switch the values of the columns on alternating rows.

 
My client wants alternating layouts on each records. So on one record the image on is the right and then on the left. They just felt it would make each record stand out more.

It's purely a design thing, and obviously we can work around it or come up with another design, but after spending a while trying to find a solution I was wondering if it was possible.

It's something that would be relatively simple do do in classic asp, by simply counting the rows and switching the content on alternating rows. I just wondered if there was any way to achieve this in a datagrid.

Not sure why you think it's such a strange thing to try. I know it's outside the normal datagrid layout, but considering it is possible to switch styles for alternating rows I thought there may also be some way of switching values.

 
I have been looking into this further, and basically want advice on the best way to page through records in .NET without using the datagrid.

Basically I want to display alternate the display/layout of each record, but I do need the paging functionality, and I will be displaying multiple records in a list.

I just want to be able to display them in a more graphically pleasing way than a standard grid layout.

I have found various tutorials and solutions on custom paging solutions, but I am not sure what the best option is.

If anyone could point me in the right direction it would be appreciated. What would you do if you needed to display records in that way?

 
I found the solution so I figured I should post it here in case anyone wants to do something similar.

I found a great article that shows how to use a repeater or datalist with the PagedDataSource class. So basically you get the paging functionality without using the a dtatgrid.


I will be combining the method used there with AlternatingItemTemplate property, which will enable me to set alternating layouts.


Phew... glad I am finally getting somewhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top