2

I have an asp:datalist bound to a database. When the user clicks a button on one of the rows, a dialog needs to be shown where the user is prompted to enter additional information.

This dialog needs some information from the item clicked. For this, I'm trying to look at Jquery Dialog and Jquery.data(). I don't know, if this is possible at all. The dialog shows up fine, but the data is not passed.

$(function () {
    $("#dialog-confirm").dialog({
        autoOpen: false,
        resizable: false,
        height: 'auto',
        width: 'auto',
        modal: true,
        buttons: {
            "OK": function () {
                $(this).dialog("close");
                var minattend = $(this).data('minattend')
                var maxattend = $(this).data('maxattend')

                DoAdditionalSearch(minattend , maxattend);
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });
});

And the ItemDataBound in code-behind:

LinkButton lnkBook = DirectCast(e.Item.FindControl("lnkBook"), LinkButton);
lnkBook.OnClientClick += "$('#dialog-confirm').data('minattend', " + countmin + ");";
lnkBook.OnClientClick += "$('#dialog-confirm').data('maxattend', " + countmax + ");";
lnkBook.OnClientClick += "$('#dialog-confirm').dialog('open'); return false;";

When I run the code, the minattend and maxattend is undefined

4

1 回答 1

0

Woops. Was passing strings, and missed a couple of "'":

lnkBook.OnClientClick += "$('#dialog-confirm').data('minattend', '" + countmin + "');"; lnkBook.OnClientClick += "$('#dialog-confirm').data('maxattend', '" + countmax + "');";

And now it works like a charm. Glad I learned this :)

于 2013-02-14T10:42:31.587 回答