locked
Merging cells in rows that contain identical data RRS feed

  • Question

  • User-1404707434 posted

    I'm new to ASP.Net and I'm trying to create two separate pages on a website I'm creating, one is People and the other is Organisations.  I have created one SQL Database in WebMatrix for both pages and I'm specifying which columns should be shown on each page through the @grid.GetHtml section in the body of my cshtml page.  As I've got them as individual rows for each contact, a lot of the data in the Company column is duplicated as there are many contacts for each company.  The Company column is the first to be shown on the Organisations page I have but is there any way I can merge the data that is duplicated so that it shows up as one company with multiple contacts beside it?

    I hope this makes sense any help is greatly appreciated.

    Friday, April 24, 2015 6:44 AM

All replies

  • User-821857111 posted

    You can group your data by company name using LINQ. I have an article which covers this technique, but groups by category instead: http://www.mikesdotnetting.com/article/189/efficiently-displaying-hierarchical-data-with-the-jquery-accordion-in-razor-web. Ignoring he Autocomplete bit, the principal should translate easily enough to your scenario.

    Friday, April 24, 2015 8:09 AM
  • User-1404707434 posted

    Thank you Mike your article was really helpful.  I've managed to adapt the information, however I was wondering whether I could include more columns rather than just the one?  For example have an organisation name as a category and a couple of columns to the right of that to include the telephone number and address.  It would also be useful to have columns for the detailed data once you've clicked on a category for contacts and their direct dials.  I hope this makes sense.

    Wednesday, April 29, 2015 5:20 AM