0
私は問題に遭遇しているように見えます。 linqを使用してXMLからデータを取得しようとしていますが、このlinqデータをListViewのDataSourceとして使用しようとすると、エラーが発生します。LINQ to XMLとViewList
どうすればいいですか?どのように私は適切な変数に私のvar変数を変換するので、ListViewは、それを受け入れるでしょうか?
コードの例は非常に高く評価されます。
Exception Details: System.InvalidOperationException: ListView with id 'showTopics' must have a data source that either implements ICollection or can perform data source paging if AllowPaging is true.
Source Error:
Line 28: showTopics.DataSource = archievePosts;
Line 29: showTopics.DataBind();
とコードビハインド:
String xmlpath = Server.MapPath("App_Data/topics.xml");
var archievePosts = from a in XElement.Load(xmlpath).Elements("topic")
where (DateTime.Parse(a.Element("topicdate").Value) <= DateTime.Parse(hDate.Text))
select new
{
topic_id = a.Attribute("id").Value.ToString(),
topic_subject = a.Element("topicname").Value,
topic_date = a.Element("topicdate").Value
};
showTopics.DataSource = archievePosts;
showTopics.DataBind();
はい私は確かに私はデータを取得しています。デバッグ中にPagerをオフにして、適切な値を返していました。今すぐあなたの方法を試してみてください。 – Dmitris
あなたの提案はうまくいった。どうもありがとうございました。 – Dmitris
いつでも男、私は助けてうれしい:) – DevMania