【发布时间】:2014-06-17 18:23:45
【问题描述】:
我有一个gridview,其中gridview 中有一些文本框和按钮。我想在单击按钮时使用更新面板,以便只刷新一个文本框而不是整个页面。我尝试在我的 gridview 中添加我的 ScriptManager 和 UpdatePanel,但我收到错误消息,提示无法识别标签。
我已经在 SO 的其他地方寻找解决方案,其他人则说将整个 gridview 放在 UpdatePanel 中。但是,我不希望更新整个网格(它很长)。我的网格视图中是否可以有单独的 UpdatePanel?
编辑:
这里有一些代码可以解决我的问题:
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="PCalendar" EventName="SelectedChange" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField HeaderText="QS">
<ItemTemplate>
<asp:TextBox ID="TextBox" runat="server" Text=' <%#Bind("PDate") %>' OnTextChanged="SetTextBox" AutoPostBack="True"></asp:TextBox>
<asp:ImageButton ID="PButton" runat="server" OnClick="ShowCalendar" ImageUrl="../images/calendarIcon.jpg" />
<asp:Calendar ID="PCalendar" runat="server" Visible="false" OnSelectionChanged="SetDate" ></asp:Calendar>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
【问题讨论】:
-
所以你有代码。您不想将更新面板放在网格中。您想将网格放在更新面板中。如果你展示你的代码,它会更容易告诉你它是如何完成的。
-
你能发布一些你的代码吗?
标签: c# asp.net gridview updatepanel