I have a webpage that is just a bunch of gridviews on the page, they display data pulled from a SQL database (using Stored procedures). I have the whole page using a javascript defined refresh function, and it works great (timer is set for every 10 mins).
I have one Gridview that I want to refresh every 15 seconds (they want that data to be the most current always). I have tried 3 different ways to get this functionality, but each has the same side effect. Instead of refreshing that specific gridview, it makes another gridview at the top of the page with the data. I'm not sure what I'm missing here, so any help would be appreciated.
Below is the code for the grid view I'm having issues with, if you need more code, please let me know.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="PDUpdatePanel" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="15000">
</asp:Timer>
<td valign="top">
<asp:GridView ID="PD" AutoGenerateColumns="true" runat="server">
</asp:GridView>
</td>
</ContentTemplate>
</asp:UpdatePanel>
EDIT
I have tried the above (using the script Manager/UpdatePanel/Trigger), I have tried using this (using the Timer1_Tick to call to rebind)
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="PDUpdatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="15000" ontick="Timer1_Tick">
</asp:Timer>
<asp:Panel runat="server">
<td valign="top">
<asp:GridView ID="PD" AutoGenerateColumns="true" runat="server">
</asp:GridView></asp:Panel>
</td>
</ContentTemplate>
</asp:UpdatePanel>
When this I tried the simple, just call the SP and rebind
protected void Timer1_Tick(object sender, EventArgs e)
{
DataAccess.PDGet(GridView PD);
}
public static void PDGet(GridView PD)
{
//Create connection
using (AdoConnNet conn = new AdoConnNet(Config.GetConfigKeys("AppName"), Config.GetConfigKeys("LogPath")))
{
conn.SetConnection(Config.GetConfigKeys("SERV_CONVEYOR"), "Conveyor");
string spTimeOutCountGet = Config.GetConfigKeys("TimeOutCountGet");
using (SqlCommand cmd = new SqlCommand())
{
//Call SP and load the results
using (SqlDataReader dr = conn.RunSPReturnDataReader(spTimeOutCountGet, cmd))
{
PD.DataSource = dr;
PD.DataBind();
}
}
}
}
Lastly, I tried making a helper function one that get the data from the Database, and another to do the binding (grasping at straws at this point).
The side effect is the same with every way I tried. Instead of refreshing the GridView PD in it's current location, it makes a new Gridview at the top of the page (and pushing the rest of the gridviews down). I'm not savvy with Web pages, so I'm unsure why it's drawing it at the top instead it's current location.
Thanks for the help!