我有devexpress gridcontrol,我想用预定义的DataTable填充数据。这是我的代码:
private void SortDataTable()
{
DataView dv = GetDataTejbl.DefaultView;
dv.Sort = comboEdit.Text + " " + "DESC";
DataTable SortedDataTable = dv.ToTable();
gridControl1.DataSource = SortedDataTable;
}
我得到的错误:
“对象引用未设置为对象的实例。”
任何帮助将不胜感激。非常感谢你
编辑:我试过的代码
if (GetDataTejbl.Rows.Count > 0)
答案 0 :(得分:1)
private void SortDataTable(){
DataView dv = GetDataTejbl.DefaultView.Sort = "["+comboEdit.Text + "] DESC";
DataTable SortedDataTable = dv.ToTable();
if(SortedDataTable!=null){
gridControl1.DataSource = SortedDataTable;
} }