我有一个 ASP .NET Web 应用程序,它使用 ListView 控件从数据库中查询和显示数据。当我在浏览器上运行 Web 应用程序时,它工作正常,但是当我在数据库中删除或添加某些内容,然后刷新运行 Web 应用程序的浏览器时,它的输出不会更新。刷新时如何使我的 Web 应用程序更新?
这是 ListView 的代码:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource">
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="HotfixIDLabel" runat="server" Text='<%# Eval("HotfixID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="HotfixIDLabel" runat="server" Text='<%# Eval("HotfixID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="HotfixIDTextBox" runat="server"
Text='<%# Bind("HotfixID") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' />
</td>
</tr>
</InsertItemTemplate>
<LayoutTemplate>
<table runat="server" border="0">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" style="">
<tr runat="server" style="">
<th id="Th1" runat="server" align="left">
<asp:LinkButton ID="LinkButton0" runat="server" CommandName="Sort" CommandArgument="HotfixID" Width="140">Update ID</asp:LinkButton></th>
<th id="Th2" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="Description" Width="600">Description</asp:LinkButton> </th>
<th id="Th3" runat="server">
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Sort" CommandArgument="Date" Width="100">Date</asp:LinkButton> </th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:TextBox ID="HotfixIDTextBox" runat="server"
Text='<%# Bind("HotfixID") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>' />
</td>
</tr>
</EditItemTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="HotfixIDLabel" runat="server" Text='<%# Eval("HotfixID") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SPDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:addremovefinalConnectionString %>"
SelectCommand="sp_getupdatesSP_v3" SelectCommandType="StoredProcedure"
onselecting="SPDataSource_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="ComboBox1" Name="param"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>