日期:2014-05-17 浏览次数:20788 次
<DataGrid Name="tenantsDg" HorizontalAlignment="Left" Width="762" AutoGenerateColumns="False" IsReadOnly="True" Margin="0,0,0,-2" >
<DataGrid.Columns>
<DataGridTextColumn Header="姓名" Width="100" Binding="{Binding name}"/>
<DataGridTextColumn Header="水费" Width="100" Binding="{Binding tel}" />
<DataGridTextColumn Header="电费"/>
<DataGridTextColumn Header="卫生治安费"/>
<DataGridTextColumn Header="电梯费"/>
<DataGridTextColumn Header="暖气费"/>
</DataGrid.Columns>
</DataGrid>
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
tenantsDg.ItemsSource = TenantsDAL.GetAll();
//进入窗口时候绑定
//GetAll方法返回的是一个List集合,断点查看里面有数据的.
}
public static List<Tenants> GetAll()
{
string sql = "select * from T_Tenants";
DataTable table = CommunityManagerSystemTools.ExecuteDataTable(sql);