H! There!

I have a problem in c# that require sorting of names of students in a sql database and i want it to be specific, i used data grid view to view the data of the students as shown below:

Students First Name:

Ann
Antoinette
Bernadette
Brenda
Jeannette
Judith
Lester
Santos
Sebastien
Suzie
Tim
Victoria

if i type in a letter or abbreviation @ a textbox1 for example "s", all Names that starts with letter s will be sorted first so the output now of the query will become:

Students First Name:

Santos
Sebastien
Suzie
Ann
Antoinette
Bernadette
Brenda
Jeannette
Judith
Lester
Tim
Victoria

So if i type j, all starts with j will be first and so on.

I need help for this problem coz it is so hard for me to output the students with this kind of sorting.

thanks in advance.

Hardz

Ok, well it's simply a matter of iterating through your data and finding the words beginning with the letters you type and moving them (NOT copy), probably into a separate array for safe keeping. Re-organise your old array alphabetically, then insert your separate array back into the old array at the beginning.

There's probably an easier way but I'm tired and it's hard to think properly :P

H!

Thank you very much! my problem was solved.

Hardz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.