How can I get the JQuery UI datepicker to display in an asp.net gridview edit box?
I have a gridview inside an update panel that does inline editing. When edit is clicked, I need the textboxes to display in JQuery UI datepicker format;
I have tried the class and id selector, tried the child selector, but JQuery cannot set this thing as datepicker because the element is not on the page yet. So I tried adding a function to the OnClientClick of the edit command and setting the datepixer there, but also doesn't seem to find the textbox. It always remains a regular text box.
Any other way?
source to share
If the textbox is added to the UpdatePanel, you need to connect to the end of the request .
// If my memory is good there was this pageLoad function that is
// automatically called by the MS AJAX Framework when the DOM has finished loading
function pageLoad(sender, args) {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function(sender, args) {
$('your_textbox_selector').datepicker();
});
}
If your page has multiple update panels, you might need to modify the end_request callback slightly, checking the parameters sender
and args
so that it binds the data file only if the UpdatePanel containing your GridView fires.
source to share