2012-11-15 29 views
1

我已經配置了我的TableAdapter Fill來執行返回行的存儲過程,並且沒有參數。但我似乎無法找到如何獲取數據。WPF TableAdapter不執行填充?

<Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:WpfDatabind3" x:Class="WpfDatabind3.MainWindow" 
    Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded_1"> 
<Window.Resources> 
    <local:cbfSQL1DataSet x:Key="cbfSQL1DataSet"/> 
    <CollectionViewSource x:Key="spTotalRevByZipViewSource" Source="{Binding spTotalRevByZip, Source={StaticResource cbfSQL1DataSet}}"/> 
</Window.Resources> 
<Grid> 
    <StackPanel HorizontalAlignment="Left" Height="292" Margin="10,10,0,0" VerticalAlignment="Top" Width="489" DataContext="{StaticResource spTotalRevByZipViewSource}"> 
     <DataGrid x:Name="spTotalRevByZipDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" Height="200" ItemsSource="{Binding}" Margin="106,0,-17,0" RowDetailsVisibilityMode="VisibleWhenSelected"> 
      <DataGrid.Columns> 
       <DataGridTextColumn x:Name="custzipColumn" Binding="{Binding custzip}" Header="custzip" Width="SizeToHeader"/> 
       <DataGridTextColumn x:Name="subTotalColumn" Binding="{Binding subTotal}" Header="sub Total" IsReadOnly="True" Width="SizeToHeader"/> 
      </DataGrid.Columns> 
     </DataGrid> 
    </StackPanel> 

</Grid> 
</Window> 

和後面的代碼是這樣的。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 

namespace WpfDatabind3 
{ 
/// <summary> 
/// Interaction logic for MainWindow.xaml 
/// </summary> 
public partial class MainWindow : Window 
{ 
    public MainWindow() 
    { 
     InitializeComponent(); 
    } 

    private void Window_Loaded_1(object sender, RoutedEventArgs e) 
    { 

     WpfDatabind3.cbfSQL1DataSet cbfSQL1DataSet = ((WpfDatabind3.cbfSQL1DataSet)(this.FindResource("cbfSQL1DataSet"))); 
     // TODO: Add code here to load data into the table spTotalRevByZip. 
     // This code could not be generated, because the cbfSQL1DataSetspTotalRevByZipTableAdapter.Fill method is missing, or has unrecognized parameters. 

     WpfDatabind3.cbfSQL1DataSetTableAdapters.spTotalRevByZipTableAdapter cbfSQL1DataSetspTotalRevByZipTableAdapter = new WpfDatabind3.cbfSQL1DataSetTableAdapters.spTotalRevByZipTableAdapter(); 
     System.Windows.Data.CollectionViewSource spTotalRevByZipViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("spTotalRevByZipViewSource"))); 
     spTotalRevByZipViewSource.View.MoveCurrentToFirst(); 
     } 
    } 
} 

我看到在負載2個TODO項目,但就像我說我的設置填充,當我在最後做預覽我得到的數據。 // ToDo後面的三行出現在我配置之後。爲什麼我沒有獲取數據?

回答

0

@StephanM

我認爲,出現這種情況,你都沒有提到DataGrid的的ItemSource,您可以嘗試下面 ItemsSource="{StaticResource spTotalRevByZipViewSource}"

我道歉,修改你的代碼,如果我有誤解的問題。

Regards