Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / February 2008

Tip: Looking for answers? Try searching our database.

Can I merge adjacent cells in a .NET 2.0 Gridview control?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew Shaw - 21 Feb 2008 22:49 GMT
I have a gridview control that is returning rows where for 1 column the
value is usually the same. Occasionally the last couple of rows will
have a different value for this column. (2 unique values total). Instead
of displaying the same value in this column for every row, I'd like to
be able to merge all the identical values into one cell, similarly to
how I could do it in Excel.

I realise that this may be going way beyond what the Gridview is
supposed to do and if its not possible to do easily then that's fine,
I'll look at other options of providing some visial indication of a
change in that value, but I'm just wondering if this can easily be done
with the gridview (since its spot on for everything else I need it for!)

Here's a rough diagram of the sort of thing I'm looking for:

Col 1 | Col 2 | Col 3 | Col 4 |
------+-------+-------+-------+
      | Val 2 | Val 3 | Val 4 |
      +-------+-------+-------+
Val 1 | Val 5 | Val 6 | Val 7 |
      +-------+-------+-------+
      | Val 8 | Val 9 | Val A |
------+-------+-------+-------+
Val B | Val C | Val D | Val E |

The above diagram probably won't look too good if your reader doesn't
have a monospaced font - sorry for that!
Riki - 23 Feb 2008 15:29 GMT
> I have a gridview control that is returning rows where for 1 column
> the value is usually the same. Occasionally the last couple of rows
[quoted text clipped - 23 lines]
> The above diagram probably won't look too good if your reader doesn't
> have a monospaced font - sorry for that!

What you want is called grouping.

Search Google for "gridview grouping", that will give you some samples how
to do it.
Mostly, it is done just by blanking out the doubles, not by merging the
cells.

Merging cells can be done easily, I think. Gridview cells inherit from
TableCell controls, which have a RowSpan property that you can set.
This also requires removing the cells below the one with the extended
rowspan (row.Cells.RemoveAt(0) or something).

Jos
Andrew Shaw - 24 Feb 2008 03:22 GMT
>> I have a gridview control that is returning rows where for 1 column
>> the value is usually the same. Occasionally the last couple of rows
[quoted text clipped - 37 lines]
>
> Jos

Excellent - thanks very much for the tips - I'll go poke Google now!

Andrew

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.