如何在不刷新整个页面的情况下刷新gridview ?
我有这个代码:
<asp:Timer ID="Timer1" runat="server" Interval="3600000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Height="250px" Width="250px">
<asp:GridView ID="Gridview1" runat="server" ></asp:GridView>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
的Gridview1
数据源应从代码隐藏(基于实时)填充,例如:
Dim DT As New System.Data.DataTable
Dim reader As SqlCeDataReader
Using myCEConnection As New SqlCeConnection(myCEConnectionString)
myCEConnection.Open()
Using myCommand As SqlCeCommand = myCEConnection.CreateCommand()
myCommand.CommandText = "SELECT ScheduleID FROM Schedule " & _
"WHERE (Hour = '"& Hour(Now) &"')"
reader = myCommand.ExecuteReader()
DT.Load(reader)
End Using
myCEConnection.Close()
End Using
Gridview1.DataSource = DT.DefaultView
Gridview1.DataBind()
Gridview1
应该每 1 小时刷新一次。我尝试了代码,但一无所获。我怎样才能做到这一点?先感谢您。