1

新しいデータを ListView にバインドしたい。しかし、私はできません

サーバー側には次のものがあります。

    [WebMethod]
    public static void ChangeConditions(string ConditionIs)
    {
        DataTable dt = new DataTable();
        dt = GetNewData(ConditionIs);

        //can't to do it, because my WebMethod is static.
        //listView.DataSource = dt;
        //listView.DataBind();
    }

    private static DataTable GetNewData(string conditions)
    {
        DataTable NewData = new DataTable();

        //Get new data from DB and want to return DataTable with new data.
        //...
        return NewData;
    }

クライアント側には次のものがあります。

$('#btnSend').live('クリック', function () {

$.ajax({
    type: "POST",
    url: "default.aspx/ChangeConditions",
    data: '{"ConditionIs":"' + condition + '"}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {

    }
}); });

データを ListView に再バインドするにはどうすればよいですか?

PSこの投稿を書くとき、私は自分の質問を調査しました。そして解決策を見つけました:

  • UpdatePanel を ListView の周りに配置します。
  • ScriptManager を UpdatePanel の上に配置します。
  • 次の行を JS の成功関数の中に入れます: __doPostBack('UpdatePanel1', '');

クライアントからサーバーにデータを [WebMethod] に送信すると、静的な DataTable にデータを入力し、Page_Load にバインドできます。しかし、私は興味を持ちたいのですが、他のソリューションを使用できますか? それとも、私のソリューションにいくつかのバグがある可能性がありますか?

4

0 に答える 0