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

Comapre Two Diffrent Grid Columns Data?

3 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rahul
Top achievements
Rank 1
rahul asked on 25 Apr 2014, 06:25 AM
hi,

I want to compare two different grid columns data. How can do this on server side. Please provide help full solutions.


Thanks,
Rahul

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Apr 2014, 07:24 AM
Hi Rahul,

You can use the OnItemDataBound event of the radgrid to access the rows and compare its values as shown below:

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem=(GridDataItem)e.Item;
        if (string.Equals(dataItem["Column1UniqueName"].Text, dataItem["Column2UniqueName"].Text))
        {
            //Your code
        }
    }
}

Thanks,
Princy
0
rahul
Top achievements
Rank 1
answered on 25 Apr 2014, 08:24 AM
hi Princy,

Thanks for quick reply, but in my case i have two different  grids but this column are same only  its data are different, so i want to compare this two grid data on button Click on server side.

Thanks
Rahul
0
Princy
Top achievements
Rank 2
answered on 25 Apr 2014, 09:16 AM
Hi Rahul,

You can try the following code snippet to compare values of two different Grid.

C#:
protected void btnCompare_Click(object sender, EventArgs e)
{
    foreach (GridDataItem frstGridDataItems in RadGrid1.MasterTableView.Items)
    {
        string frstgridValue = frstGridDataItems["ColumnUniqueName"].Text;
        foreach (GridDataItem scndGridDataItem in RadGrid2.MasterTableView.Items)
        {
            string scndgridValue = scndGridDataItem["ColumnUniqueName"].Text;
            if (string.Equals(frstgridValue, scndgridValue))
            {
                //Your code
            }
        }
    }
}

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