Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Can I merge adjacent cells in a .NET 2.0 Gridview control?

Reply
Thread Tools

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

 
 
Andrew Shaw
Guest
Posts: n/a
 
      02-21-2008
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!
 
Reply With Quote
 
 
 
 
Riki
Guest
Posts: n/a
 
      02-23-2008
Andrew Shaw wrote:
> 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!


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


 
Reply With Quote
 
 
 
 
Andrew Shaw
Guest
Posts: n/a
 
      02-24-2008
Riki wrote:
> Andrew Shaw wrote:
>> 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!

>
> 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
>
>


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

Andrew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spreadsheet Excel: How to merge cells? Michael Schmarck Ruby 1 01-29-2008 12:06 PM
convert yyyymmdd text cells into date cells =?Utf-8?B?ZF9jYW1wZWxvQGhvdG1haWwuY29t?= Microsoft Certification 2 11-22-2006 04:52 PM
Writing to Cells in the Detailsview Insertmode makes cells uneditable. SixStringSlaya@gmail.com ASP .Net 0 02-28-2006 10:23 PM
Re: Merge cells Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 1 06-24-2004 11:21 PM
Merge cells Mark Goldin ASP .Net 1 06-24-2004 11:16 AM



Advertisments