データセットに「日付」という列があります。この列を現在の日付でフィルタリングしたいと思います。 今日のすべての注文(現在の日付)を表示したい。現在の日付でデータセットをフィルタリングします。
私はこれを試してみましたが、それは働いていない:
DataSet ds = new DataSet();
ds.ReadXml("C:\\sites.xml");
dataGridView1.DataSource = ds.Tables[0];
this.dataGridView1.Columns[1].Visible = false;
//filter
ds.Tables[0].DefaultView.RowFilter = "date = '" + DateTime.Now.ToString() + "'";
XMLファイル:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<site technical="1">
<name>brian</name>
<url>www.microsoft.com</url>
<date>01/02/2012</date>
</site>
<site technical="2">
<name>Mike</name>
<url>www.news.com</url>
<date>01/02/2012</date>
</site>
<site technical="3">
<name>leslie</name>
<url>www.cnet.com</url>
<date>02/01/2012</date>
</site>
<site technical="4">
<name>rebeca</name>
<url>www.gamespot.com</url>
<date>01/01/2012</date>
</site>
<site technical="5">
<name>jenifer</name>
<url>www.google.com</url>
<date>02/01/2012</date>
</site>
</sites>
「機能していません」とは、人々が思うほど多くの情報を提供しません。エラーの場合は、メッセージを入力します。予期せぬ結果だった場合は、それが何だったのか、また期待したことを教えてください。 –
私はフィルタリングしようとしたときに、エラーメッセージが表示されず、カラムがdatagridviewに空になっています。これはXMLファイルです。 – user1112847