我在更新面板中有一个网格视图,就像这样。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#D9EFFD" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1"
Font-Names="Tahoma" Font-Size="8pt" GridLines="Horizontal" Width="100%" ForeColor="#010101"
ShowHeaderWhenEmpty="True">
<Columns>
<asp:BoundField DataField="MODE_TPT_ENTRY" HeaderText="Balance" SortExpression="MODE_TPT_ENTRY">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Font-Bold="True" HorizontalAlign="Left" Width="120px" ForeColor="#035BAC" />
</asp:BoundField>
<asp:BoundField DataField="OB" HeaderText="Opening" SortExpression="OB">
<ItemStyle HorizontalAlign="Right" Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="ISSUED" HeaderText="Arrival" SortExpression="ISSUED">
<ItemStyle HorizontalAlign="Right" Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="UNTARE" HeaderText="UNTARE" SortExpression="UNTARE" Visible="False" />
<asp:BoundField DataField="TARE" HeaderText="Tare" SortExpression="TARE">
<ItemStyle HorizontalAlign="Right" Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="BALANCE" HeaderText="Balance" SortExpression="BALANCE">
<ItemStyle HorizontalAlign="Right" Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="RRY" HeaderText="Recovery" SortExpression="RRY">
<ItemStyle HorizontalAlign="Right" Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="TRANSPORT_NO" HeaderText="TRANSPORT_NO" SortExpression="TRANSPORT_NO"
Visible="False" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#D9EFFD" Font-Bold="True" ForeColor="#010101" HorizontalAlign="Right" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#101010" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>" SelectCommand="SELECT * from cms_production">
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
和一个像这样在 5 秒后刷新面板的 JavaScript 函数
<script type="text/javascript">
window.setInterval(function () {
__doPostBack('<%= UpdatePanel1.ClientID %>', '');
}, 5000);
</script>
问题是,当我更改与 gridview 绑定的数据时,五秒钟后不会显示任何更改。任何人都可以告诉我我的代码中有什么问题或任何其他要添加到我的代码中以使 gridview 在更新面板中更新没有页面重定向。