Hi zzz,
I have created one sample that full-fill your requirement.
HTML
<div>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false" OnRowDataBound="DataBound">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
</Columns>
</asp:GridView>
</div>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] {
new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "John Hammond", "United States");
dt.Rows.Add(4, "Mudassar", "India");
dt.Rows.Add(5, "Mudassar Khan", "India");
dt.Rows.Add(6, "Suzanne Mathews", "France");
dt.Rows.Add(7, "Suzanne", "France");
dt.Rows.Add(8, "Suzanne", "France");
dt.Rows.Add(9, "Mudassar Khan", "India");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void DataBound(object sender, GridViewRowEventArgs e)
{
for (int current = 0; current < GridView1.Rows.Count; current++)
{
for (int other = current + 1; other < GridView1.Rows.Count; other++)
{
GridViewRow compareRow = GridView1.Rows[current];
GridViewRow row = GridView1.Rows[other];
if (((compareRow.Cells[1].Text) == (row.Cells[1].Text)) && ((compareRow.Cells[2].Text) == (row.Cells[2].Text)))
{
compareRow.BackColor = Color.Green;
row.BackColor = Color.Green;
}
}
}
}
Screenshot
