Sort items in datatable

后端 未结 5 764
臣服心动
臣服心动 2020-12-19 12:01

I have a datatable with one column that contain names.I want to load combobox with datatable such that names should be in alphabetic order for eg:first name starts with a. s

5条回答
  •  梦毁少年i
    2020-12-19 12:57

    use an typed dataset create a datatable in precising type of data for example i have create a dsAppointment

     DsAppointment dsAppointmentTmp = new DsAppointment();
     DsAppointment dsAppointment = new DsAppointment();
    //add all appointment
     dsAppointmentTmp.Appointment.AddAppointmentRow(name,start,end,body)
    //use select(filter,sort(name of columns)
    DataRow[] rows1 = dsAppointmentTmp.Tables[0].Select(string.Empty, dsAppointmentTmp.Tables[0].Columns[1].ToString());
    
                foreach (DataRow thisRow in rows1)
                {
                        dsAppointment.Tables[0].Rows.Add(thisRow.ItemArray);
    
                }
    

    //return dsAppointment sorted return dsAppointment;

提交回复
热议问题