Datagrid column merging & Column Header Text Change in multi line

Posted on 2004-11-08
Last Modified: 2008-01-09

I would like to mearge two columns 0f datagrid. and also i want to display the columns title in multiple line by using c#.

Question by:arvsha
    LVL 8

    Accepted Solution

    As far as i know, Merging isnt possible

    DataColumn dc;
    dc.ColumnName = "Column One"
    dc.Caption = "Column\nOne";   //\n is new line character

    LVL 2

    Expert Comment

    Hi, I'm not sure if I understand your question correctly. But I had an occasion where I had to merge two columns in the footer and I did as the following.
    (1) In your ItemDataBound method,             
      if (e.Item.ItemType == ListItemType.Footer)
         e.Item.Cells[0].Text = "Merge Col1 and col2";
         e.Item.Cells[1].Visible = false;
    (2) to display the columns title in multiple line
    In your ItemDataBound method,             
      if (e.Item.ItemType == ListItemType.Header)
         e.Item.Cells[0].Text = "line1<br>line2";


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now