我想对绑定到下拉列表的数据进行排序。Dropdown中的数据排序
我从数据库中取出学生的名字,但认为我不能直接使用orderby。
因为我从数据库中获得的数据是Guid类型的学生ID。
然后我从ID找到全名。
下面的代码
public DataTable GetAllStudentNameFromMentor(Guid MentorId)
{
DataTable AllStudents = new DataTable();
AllStudents.Columns.Add("StudentID", typeof(Guid));
AllStudents.Columns.Add("studentName", typeof(string));
var allm = from sm in Db.StudentMentor
where sm.MentorID.Equals(MentorId)
select sm;
foreach (var v in allm)
{
string studentname = BussinesCollection.BussinesPerson.GetFullName(v.StudentID.Value);
AllStudents.Rows.Add(v.StudentID,studentname);
}
return AllStudents;
}
我绑定表中的下拉列表。
ddlstudent.DataSource = m.bussinesCollection.BussinesMentor.GetAllStudentNameFromMentor(MentorID);
ddlstudent.DataBind();
但我想名字应该按字母顺序。
会有人愿意帮助我..
它的工作完全适合我..谢谢了很多.. –