views:

345

answers:

2

How to compare 2 gridviews which bind to a same table in C#?

  1. For example if the table name is employees, i need to bind to two grids - Grid1 and Grid2.

  2. The Employees tables reside in two different Access databases.

    Grid1- Connects to Database1 - Binds Employee table and Grid2- Connects to Database2 - Binds Employee table

  3. If i have 3 rows in Grid1 and if i have 2 rows in Grid2, then 3rd row of Grid1- Connects to Database1 - Binds Employee should be shown in red color and when i click an update button outside the grid, the 3rd row should be updated in Grid2.

Comparing and Syncing

Please give some help on this.

Thanks in advance.

A: 

Do this on buttonclick. I'm not sure i understand your question fully but just bind them then compare them.

If gridview1.rows.count > gridview2.rows.count then

 GridView1.Rows(GridView1.Rows.Count - 1).backcolor = red

end if
Eric
A: 

Why don't you compare datatables? Get index of rows which are different in a collection. Then iterate through each row of gridview and set the background color as Eric has suggested.

P.K