DataTable as DataGrid.ItemsSource

后端 未结 1 1053
無奈伤痛
無奈伤痛 2020-12-06 17:37

hi i want to bind a DataTable with multiple columns to an DataGrid in codebehind

    var dt = new DataTable();

    dt.Columns.Add(         


        
相关标签:
1条回答
  • 2020-12-06 18:05

    Assuming you're in WPF simply say:

    DGrid.ItemsSource = dt.AsDataView();
    

    No need to manually setup your columns on your DataGrid, assigning the DataTable will set these up for you.

    0 讨论(0)
提交回复
热议问题