This is a migrated thread and some comments may be shown as answers.

Upper limit on number of data columns in a datagrid

2 Answers 354 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cha
Top achievements
Rank 1
cha asked on 30 Oct 2013, 05:18 PM
Can some one please tell me the upper limit for number of data columns in a telerik datagrid ? I know if I have more than 255 then export to excel wouldn't work. Just wanted to know how many does the data grid allows if I dont plan on using export features.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Oct 2013, 11:49 AM
Hi,

As far as I know RadGrid does not have a limit for the columns that it can contain. So you should have in mind that hundreds columns in your RadGrid instance may slow the performance down.With such large amount of fields in the grid table you may consider utilizing the scrolling + static headers feature of our web grid and enable its paging feature to reduce the number of records displayed at once.

Thanks,
Princy.
0
Konstantin Dikov
Telerik team
answered on 04 Nov 2013, 09:51 AM
Hello Cha,

The limitation of the number of columns is int.MaxValue, but you will face performance issues with huge amount of columns.

Here is a code snippet that will allow you to test different number of columns and rows:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"></telerik:RadGrid>
and the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
 
    int columnCount = 500;
    for (int i = 0; i < columnCount; i++)
    {
        table.Columns.Add("Column" +i, typeof(string));
    }
 
    for (int i = 0; i < 50; i++)
    {
        table.Rows.Add();
        for (int z = 0; z < columnCount; z++)
        {
            table.Rows[i]["Column" + z] = z;
        }
    }
 
    RadGrid1.DataSource = table;
}

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
cha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or