span cells in grid over multiple positions

Thread is closed for posting
3 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 14 Feb 2007 Link to this post


    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    4.5.x and later

    2008.1.415 and later

    .NET version

    2.0 and later

    Visual Studio version

    2005 and later

    Programming language


    Browser support

    all supported by RadGrid for ASP .NET

    all browsers supported by RadControls for ASP .NET AJAX

    This project demostrates how to span any given cell over a number of rows/columns, with autogenerated columns in the control. This can be useful when you want to add additional information pertaining only to a small subset of the data in the control.
  2. AD042491-5103-48CC-8FEB-C89A8BEEE477
    AD042491-5103-48CC-8FEB-C89A8BEEE477 avatar
    18 posts
    Member since:
    Oct 2008

    Posted 31 Oct 2008 Link to this post

    This solution doesn't work when the page is posted back. When it is posted back an additional column is added to the far right. To reproduce just add a button to the page and click it.  What is causing this?
  3. 23C72464-8FC9-43C3-9A12-B431B37B7758
    23C72464-8FC9-43C3-9A12-B431B37B7758 avatar
    11 posts
    Member since:
    Dec 2013

    Posted 03 Nov 2008 Link to this post

    Hello Sean,

    To eliminate the issue, you can alter the code-behind to:

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    using Telerik.WebControls;  
    public partial class _Default : System.Web.UI.Page  
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
            DataTable table = new DataTable();  
            table.Rows.Add(new object[] { "Cell11", "Cell12", "Cell13" });  
            table.Rows.Add(new object[] { "Cell21", "Cell22", "Cell23" });  
            table.Rows.Add(new object[] { "Cell31", "Test", "Test" });  
            table.Rows.Add(new object[] { "Test", "Cell42", "Cell43" });  
            table.Rows.Add(new object[] { "Test", "Cell52", "Cell53" });  
            RadGrid1.DataSource = table;  
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        protected void RadGrid1_PreRender(object sender, EventArgs e)  
            foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)  
                if (dataItem["Column2"].Text == dataItem["Column3"].Text)  
                        dataItem["Column2"].ColumnSpan = 2;                      
                        dataItem["Column3"].Visible = false;  
                    int previousItemIndex = dataItem.ItemIndex - 1;  
                    if (previousItemIndex >= 0)  
                        if (dataItem["Column1"].Text == dataItem.OwnerTableView.Items[previousItemIndex]["Column1"].Text)  
                            dataItem.OwnerTableView.Items[previousItemIndex]["Column1"].RowSpan = 2;                          
                            dataItem["Column1"].Visible = false;  

    I hope this helps.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.