Tuesday, October 31, 2006

Removing Duplicates Item from DropDownList

public static void RemoveDuplicateItems(DropDownList ddl)
{

for (int i = 0; i < ddl.Items.Count; i++)
{
ddl.SelectedIndex = i;
string str = ddl.SelectedItem.ToString();
for (int counter = i + 1; counter < ddl.Items.Count; counter++)
{
ddl.SelectedIndex = counter;
string compareStr = ddl.SelectedItem.ToString();
if (str == compareStr)
{
ddl.Items.RemoveAt(counter);
counter = counter - 1;
}
}
}
}

4 comments:

Anonymous said...

Thank you Very much this has helped me a lot.

Vuyiswa Maseko

a said...

Thanks for sharing

Na said...

thanks U It working greattttttt job

Unknown said...

who to write method
because i copy/ paste
no slove problem
please help me

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape