【发布时间】:2015-03-20 06:09:26
【问题描述】:
我在 UpdatePanel 内的 GridView 内使用 eWorldUI 日历弹出窗口(底部链接)。
如果我没有将我的页面表单内容放在 UpdatePanel 中,那么当我更新 Gridview 的一行时,日历会很好地刷新。但是,当所有内容都在 UpdatePanel 中时,日历不会刷新,因此它始终保持第一行日历的 ID。
我的问题是:
GridView 控件“在 UpdatePanel 内”和“在 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 之后。
【问题讨论】:
-
对不起,如果它看起来很具体,我可以用任何控件问同样的问题,所以答案不一定是关于日历的。
标签: asp.net ajax gridview webforms user-controls