if(dt.Columns.IndexOf("name") != -1) //存在这个字段

{

dt.DefaultView.Sort = "name asc";
dt=dt.DefaultView.ToTable();

}