1

ドロップダウンリストを使用して特定のデータソースをアタッチすると、このエラーが発生します。他のすべてのテーブル/データソースで正常に動作します。javascript/jqueryを使用してドロップダウンリストに変更を加えていません(現在を除く他のすべてのデータソースで正常に機能するため)

エラー:

Invalid postback or callback argument.  Event validation is

構成で使用するか、ページで <%@ Page EnableEventValidation="true" %> を使用して有効にします。セキュリティ上の目的で、この機能は、ポストバック イベントまたはコールバック イベントへの引数が、それらを最初にレンダリングしたサーバー コントロールから発信されていることを確認します。データが有効で期待される場合は、ClientScriptManager.RegisterForEventValidation メソッドを使用して、検証のためにポストバックまたはコールバック データを登録します。

xml ファイルから値を取得する関数:

public List<ProductReviewmaster> ConvertRssXDocToReviews(XDocument xdoc)
{
    List<ProductReviewmaster> nl = new List<ProductReviewmaster>();

    if (xdoc != null)
    {
        var res = from rs in xdoc.Descendants("item")
                  select new ProductReviewmaster()
                  {
                      Title = rs.Element("title").Value,
                      ShortHeadLine = rs.Element("shortheadline").Value,
                      Link = rs.Element("link").Value,
                      Reviewid = rs.Element("guid").Value ,
                      //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                      Image = rs.Element("storyimage").Value,
                      Dateline = rs.Element("dateline").Value,
                      Excerpt = rs.Element("excerpt").Value,
                      Tags = rs.Element("tags").Value,
                      ProductId = rs.Attribute("productid").Value.ToInt64()
                  };
        foreach (var item in res)
        {
            nl.Add(item);

        }
    }
    return nl;


}

これは、ドロップダウンリストでそれをバインドする方法です:

   ddlReview.DataSource =  prmf.GetReviewByCategoryKey(categoryid);
                ddlReview.DataValueField = "Reviewid";
                ddlReview.DataTextField = "Title";
                ddlReview.DataBind();
                ddlReview.Items.Insert(0, new ListItem("---Select---"));

同じドロップダウンリストを他のデータソース(xml以外)にバインドすると、正常に動作します..しかし、このデータソースで実行すると、上記のエラーがスローされます。

私のxmlは次のようなものです:

<rss version="2.0">
  <channel>
    <title>

        </title>
    <link>

        </link>
    <language>en</language>
    <lastBuildDate>
            August  3, 2011  3:57 PM
        </lastBuildDate>
    <image>
      <url></url>
      <link>
            </link>
    </image>
    <items>
      <item productid="">
        <title><![CDATA[This is new test review]]></title>
        <shortheadline><![CDATA[]]></shortheadline>
        <link>

                    </link>
        <permaLink>
          <web>

                        </web>
        </permaLink>
        <guid isPermaLink="false">
                        29527
                    </guid>
        <pubDate>
                        August  2, 2011  1:56 PM
                    </pubDate>
        <MobileText></MobileText>
        <storyimage><![CDATA[ges/apple-appstore.jpg]]></storyimage>
        <categories><![CDATA[mobile]]></categories>
        <dateline><![CDATA[]]></dateline>
        <excerpt><![CDATA[isational structure for its operations in India and South Asia with effetransformational business...]]></excerpt>
        <tags><![CDATA[mobile, phone]]></tags>
        <contenttype><![CDATA[Review]]></contenttype>
      </item>
    </items>
    <description></description>
  </channel>
</rss>

データを正常に取得してドロップダウンリストに表示しますが、そこからアイテムを選択すると(選択したインデックスが変更されます)、このメッセージが表示されます...

ありがとう

4

2 に答える 2

1

最後に、問題を解決しました... LINQを使用しているときに、Trim()を使用して完了しました... :)

var res = from rs in xdoc.Descendants("item")
                          select new ProductReviewmaster()
                          {
                              Title = rs.Element("title").Value.Trim(),
                              ShortHeadLine = rs.Element("shortheadline").Value.Trim(),
                              Link = rs.Element("link").Value.Trim(),
                              Reviewid = rs.Element("guid").Value.Trim() ,
                              //Pubdate = Convert.ToDateTime( rs.Element("pubdate").Value),
                              Image = rs.Element("storyimage").Value.Trim(),
                              Dateline = rs.Element("dateline").Value.Trim(),
                              Excerpt = rs.Element("excerpt").Value.Trim(),
                              Tags = rs.Element("tags").Value.Trim(),
                              ProductId = rs.Attribute("productid").Value.ToInt64()
                          };

だから私の最後の結論は、価値のある空白の問題がなければならないということです...

于 2011-08-04T06:20:24.510 に答える
1

このエラーは通常、ドロップダウンリストを含む入力要素にこれらの文字 '<' または '>' のいずれかが含まれている場合に発生します。

それらの値が存在する場合、それらの値をエンコードしようとしましたか?

于 2011-08-04T06:13:51.773 に答える