How-To Sort a Dropdownlist

  • Thread starter Thread starter gj
  • Start date Start date
G

gj

Hi,

I'm trying to sort a dropdownlist. I tried using .Sort but that
doesn't work. can anyone help me? Below is the code for creating the
list.

foreach (DataRow quizRow in dsMain1.Tables["Quiz"].Rows)

{

ListItem newquiz= new ListItem();

newquiz.Text=quizRow["Quiz_Name"].ToString().Trim();
newquiz.Value=quizRow["Quiz_ID"].ToString().Trim();
drpSelectQuiz.Items.Add(newquiz);
} //end foreach loop

Thanks
 
gj,

Why are you adding the items manually? Why not bind the list to the
data set directly?
 
Back
Top