TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajkumar R
NA
26
3.6k
Compare Gridviews
Sep 14 2017 4:39 AM
HI,
I have 2 gridviews with same columns, but there is a difference in data. Would like to compare 2 gridivews and show the difference data in another gridview or highlight the row
can you please suggest
the below code is highlighting the entire columns for all rows, it should highlight only specific cells which has the difference in data
private void Compare(GridView g1, GridView g2)
{
foreach (GridViewRow row1 in g1.Rows)
{
if (row1.RowType == DataControlRowType.DataRow)
{
string gv1Value = row1.Cells[2].Text;
//iterate second gridview
foreach (GridViewRow row2 in g2.Rows)
{
if (row2.RowType == DataControlRowType.DataRow)
{
string gv2Value = row2.Cells[2].Text;
string gv4Valuke = row2.Cells[1].Text;
//do comparison here
if (gv1Value.Contains(gv2Value))
{
g1.Rows[row1.RowIndex].Cells[2].BackColor = System.Drawing.Color.Blue;
}
}
}
}
}
Reply
Answers (
3
)
How Export data into excel in mvc4 directly ?
ApplicationUser is not part of the model for the context