本帖最后由 贰的23次方 于 2014-4-4 12:57 编辑
数据库两张表的model如下
public class User
{
public Guid ID { set; get; }
public string UserName { set; get; }
public string Password { set; get; }
public bool IsDeleted { set; get; }
public bool IsLocked { set; get; }
public string RealName { set; get; }
}
public class T_OperLog
{
public System.Guid ID { get; set; }
public System.Guid OperID { get; set; }
public System.String Action { get; set; }
public System.DateTime OperDate { get; set; }
public System.Boolean IsDeleted { get; set; }
}
在datagrid中显示( 日期 操作员 行为)(
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding OperDate}" Header="日期" Width="150"></DataGridTextColumn>
<DataGridComboBoxColumn x:Name="cmbOperName" SelectedValueBinding="{Binding OperID}" DisplayMemberPath="UserName" SelectedValuePath="ID" Header="操作人" Width="110"></DataGridComboBoxColumn>
<DataGridTextColumn Binding="{Binding Action}" Header="行为" Width="250"></DataGridTextColumn>
<DataGrid.Columns>
设置数据源如下
string sql = "select * from T_OperLog where " + string.Join(" and ", whereList);
T_OperLogDAL op = new T_OperLogDAL();
dataGridLog.ItemsSource = op.SearchLog(sql, paramaters);
结果显示出了日期和行为,操作员(用DataGridComboBoxColumn绑定)没显示出来,但是数据库中是有的,并且下断点, dataGridLog.ItemsSource 也是有的,但是为什么显示不出呢?
|