The Web application does not update when it is updated

advertisements

I have an ASP .NET Web Application that queries and shows data from a database using ListView Control. When I run the Web App on the browser it works fine, but when I delete or add something in the database, then refresh the browser where the web app is running, its output does not update. How can I make my Web App update when refreshed?

This is the code for the 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>


Well, as the comments alluded to, clearly the page is being cached. You can verify this by adding a directive to the top of your page:

<%@ OutputCache Location="None" %>

That means that your database will be hit for every request, though. For a better solution I recommend looking into SQL cache dependencies.