在 UpdatePanel 中时,不会刷新 GridView 中的用户控件 CalendarPopup

User control CalendarPopup inside a GridView is not refreshed when inside an UpdatePanel

我在 UpdatePanel 内的 GridView 内使用 eWorldUI 日历弹出窗口(link 在底部)。

如果我不将我的页面表单内容放在 UpdatePanel 中,当我更新 Gridview 的一行时,日历会正常刷新。但是,当所有内容都在 UpdatePanel 中时,日历不会刷新,因此它始终保留第一行日历的 ID。

我的问题是:

GridView 控件"within UpdatePanel" 和"outside of UpdatePanel" 有什么区别,生成日历的控件的事件HTML 有什么原因根本不会发生或根本不会发生在我更新 UpdatePanel 中的一行 gridview 后的正确时刻发生? 解决问题的提示也很受欢迎:)

这里是一个示例代码(请注意后面的代码中设置了gridview数据源)

<html>
<head> <!-- head stuff --> </head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server"></asp:scriptmanager>
<asp:updatepanel id="UpdatePanel1" runat="server"><contenttemplate>
<asp:gridview id="GRIDVIEW1" showheader="False" showfooter="False" runat="server" autogeneratecolumns="false" onrowdatabound="GridView_RowDataBound">                               
<Columns>
    <asp:TemplateField>
        <HeaderTemplate> ...    </HeaderTemplate>
        <HeaderStyle cssclass="..."></HeaderStyle>
        <FooterTemplate> ... </FooterTemplate>
        <FooterStyle cssclass="..."></FooterStyle>
        <EditItemTemplate>
            <asp:textbox id="GRIDVIEW1_DATE1" text="<%# Bind('GRIDVIEW1_DATE1') %>" runat="server"></asp:textbox>
            <ew:calendarpopup imageurl="../../App_Themes/Images/calendar.gif" controldisplay="Image" id="GRIDVIEW1_DATE1_CAL" runat="server"></ew:calendarpopup>
        </EditItemTemplate>
        <ItemTemplate>
            <asp:Label id="GRIDVIEW1_DATE1" runat="server" text='<%# Bind("GRIDVIEW1_DATE1") %>'></asp:Label>
        </ItemTemplate>
        <ItemStyle cssclass="..."></ItemStyle>
    </asp:TemplateField>
    <asp:CommandField buttontype="Button" showdeletebutton="True" showeditbutton="True" causesvalidation="False" insertvisible="False"></asp:CommandField>
</Columns>
</asp:gridview>
</contenttemplate></asp:updatepanel>
</form>
</body>
</html>

这是有问题的日历 - http://www.eworldui.net/CustomControls/CalendarPopupDemo.aspx

编辑

我发现我的问题实际上是因为日历生成的动态HTML实际上是在<form>里面,但它是在UpdatePanel之外添加的。这并不明显,因为如您所见,所有内容似乎都在 UpdatePanel 中。所以为了测试它,我在 UpdatePanel 外添加了一个 <div class="outsideUpdatePanel"></div>,当在 Chrome 中启动并检查 HTML 时,我可以看到生成的日历 HTML 出现在我的新 div.

更新面板内外的 GridView 没有区别。
整页生命周期在这两种情况下都会发生。
唯一不同的是,只有UpdatePanel的ContentTemplate的内容传回给浏览器。

您没有指定 Gridview DataSourceID 属性 因此您必须管理数据绑定。确保在更新后重新绑定 GridView。

而且我不得不问这个,因为我看不到你的数据源字段列表,但它实际上包含一个名为 GRIDVIEW1_DATE1 的字段吗?我只是想确认您不是要使用它的 ID

绑定到 Gridview TextBox 控件

编辑:另外,仅供参考,如果您正在为 HTML5 开发,您可以将文本框 TextMode 属性 设置为 Date 并使用现代浏览器的内置日历弹出窗口。 (Text 属性 必须格式化为 yyyy-mm-dd