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

Get RadGrid output as Dataset

2 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 16 Jan 2010, 05:56 PM
Hi,

I searching one solution to export current modified RadGrid in one dataset to use in some custom code c#. Thanks for u.help. 

2 Answers, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 1
answered on 10 Jun 2013, 07:13 PM
No one can answer this question??
0
Daniel
Telerik team
answered on 13 Jun 2013, 02:10 PM
Hello Sean,

You can traverse the items/columns and build the desired DataTable/DataSet if this is what you are after.
protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
 
    DataTable table = new DataTable();
    foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
    {
        if (col.Visible)
        {
            table.Columns.Add(col.UniqueName);
        }
    }
 
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        List<string> list = new List<string>();
        foreach (DataColumn column in table.Columns)
        {
            list.Add(item[column.ColumnName].Text);
        }
        table.Rows.Add(list.ToArray());
    }
}

Regards,
Daniel
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
Pierre
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or