如题

解决方案 »

  1.   

    先建一个SqlDataAdpater放入你的表到DataSet
    右击你的DataGrid,属性设置,然后 DataGrid.source = Dataset
      

  2.   

    see:private void BindToDataView(DataGrid myGrid){
        // Create a DataView using the DataTable.
        DataTable myTable = new DataTable("Suppliers");
        // Insert code to create and populate columns.
        DataView myDataView = new DataView(myTable);
        myGrid.DataSource = myDataView;
     }
     private void BindToDataSet(DataGrid myGrid){
        // Create a DataSet.
        DataSet myDataSet = new DataSet("myDataSet");
        // Insert code to populate DataSet with several tables.
        myGrid.DataSource = myDataSet;
        // Use the DataMember property to specify the DataTable.
        myGrid.DataMember = "Suppliers";
     }
     private DataView GetDataViewFromDataSource(){
        // Create a DataTable variable, and set it to the DataSource.
        DataView myDataView;
        myDataView = (DataView) dataGrid1.DataSource;
        return myDataView;
     }
     private DataSet GetDataSetFromDataSource(){
        // Create a DataSet variable, and set it to the DataSource.
        DataSet myDataSet;
        myDataSet = (DataSet) dataGrid1.DataSource;
        return myDataSet;
     }