一个关于datatable.Relations问题
原先代码如下,可以正常运行
...
ds.Tables.Add(dt.Copy());
ds.Tables[0].TableName = "Voucher";
...
ds.Tables.Add(dt.Copy());
ds.Tables[1].TableName = "Entry";
ds.Relations.Add("EntryOfVoucher", ds.Tables["Voucher"].Columns["id"], ds.Tables["Entry"].Columns["VoucherId"]);
RepeaterVTVoucher.DataSource = ds.Tables["Voucher"];
RepeaterVTVoucher.DataBind();
后来需要在第一个dt中过滤一下
于是改了下,红色为添加代码
...
dt.DefaultView.RowFilter = "status<>'D'";
ds.Tables.Add(dt.DefaultView.ToTable().Copy());
ds.Tables.Add(dt.Copy());
ds.Tables[0].TableName = "Voucher";
...
ds.Tables.Add(dt.Copy());
ds.Tables[1].TableName = "Entry";
ds.Relations.Add("EntryOfVoucher", ds.Tables["Voucher"].Columns["id"], ds.Tables["Entry"].Columns["VoucherId"]);
RepeaterVTVoucher.DataSource = ds.Tables["Voucher"];
RepeaterVTVoucher.DataBind();
结果报以下错
Cannot add a DataRelation or Constraint that has different Locale or CaseSensitive settings between its parent and child tables.
哪位知道什么问题?谢谢了