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

Compare Grids

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 1
Naresh asked on 21 Oct 2013, 01:53 PM
How to compare changes for intially loaded radgrid to the same radgrid on submit? Is there any way to compare in telerik or store in list and compare?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 22 Oct 2013, 10:01 AM
Hi Naresh,

There is no direct approach to compare the data in RadGrid before and after submit. One suggestion is to save the DataSource (DataTable) in session variable while the RadGrid loads for the first time and compare with the data in RadGrid after submit button click. Here is the code snippet I tried to get the data in RadGrid in a DataTable on a Button Click event.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    DataTable dtRecords = new DataTable();
    foreach (GridColumn col in RadGrid1.Columns)
    {
        DataColumn colString = new DataColumn(col.UniqueName);
        dtRecords.Columns.Add(colString);
 
    }
    foreach (GridDataItem row in RadGrid1.Items) // loops through each rows in RadGrid
    {
        DataRow dr = dtRecords.NewRow();
        foreach (GridColumn col in RadGrid1.Columns) //loops through each column in RadGrid
            dr[col.UniqueName] = row[col.UniqueName].Text;
        dtRecords.Rows.Add(dr);
    }      
}

Let me know if you have any concern.

Thanks,
Princy.
Tags
Grid
Asked by
Naresh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or