Hello Vijay, you have to loop through all the rows in your GridView control and compare if there is any duplicate value. Try the following code:
bool foundDuplicate = false;
for (int i = 0; i < GridView1.Rows.Count - 1; i++)
{
DropDownList ddl1 = (DropDownList)GridView1.Rows[i].FindControl("ddlName");
for (int j = i + 1; j < GridView1.Rows.Count; j++)
{
DropDownList ddl2 = (DropDownList)GridView1.Rows[j].FindControl("ddlName");
if (ddl1.SelectedValue == ddl2.SelectedValue)
{
foundDuplicate = true;
break;
}
}
if (foundDuplicate == true)
{
break;
}
}
Let me know if you have any further query.
- DD