Link to home
Start Free TrialLog in
Avatar of kurtcobain123
kurtcobain123

asked on

ASP.NET refresh the data every 15 sec and retain the values already populated in the page

ASP.NET
I am using    <meta http-equiv="refresh" content="300">
for refreshing the auto refreshing the page in ASP.NET
, however the values of the list and text box get lost when i do this.

i tried using enableviewstate but still the values are not retained.
is there any way i can auto refresh the data of a page after every 15 sec and retain the values already populated in the page
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

How are you binding the data in the Page_Load event?

Bob
Avatar of kurtcobain123
kurtcobain123

ASKER

i call a function for binding the data

rdDisplay_SelectedIndexChanged(null,System.EventArgs.Empty);


which has all the dataloading functions... based on selection of the radiobutton.
the problem is that this selection gets lost if i use the meta tag

AB
When the refresh occurs, the page is reloaded.  Can you show me the rdDisplay_SelectedIndexChanged code, and the Page_Load, please?

Bob
here u go .....
#region Page_Load
            private void Page_Load(object sender, System.EventArgs e)
            {

                  if (!Page.IsPostBack)
                  {
                        rdDisplay.SelectedIndex = 0;
                  }

                  OracleConnection oConn = new OracleConnection(System.Configuration.ConfigurationSettings.AppSettings["dbConnection"]);
                  oConn.Open();
                  OracleCommand cmd = oConn.CreateCommand();
                  string SQLString =  " select to_char(sysdate,'dd Mon yy hh24:mi:ss') as dt from dual " ;
                  OracleCommand oCmd = new OracleCommand(SQLString, oConn);
                  
                  DataSet ds = new DataSet();
                  OracleDataAdapter adapter = new OracleDataAdapter(oCmd);
                  adapter.Fill(ds);
                  LblRefreshdate.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                  oConn.Close();
                  rdDisplay_SelectedIndexChanged(null,System.EventArgs.Empty);


            }
            #endregion

#region rdDisplay_SelectedIndexChanged
            private void rdDisplay_SelectedIndexChanged(object sender, System.EventArgs e)
            {
                  if(rdDisplay.SelectedIndex == 0)  //all
                  {
                        btnShow.Visible = false;
                        ScheduleGeneral1.FullTimeScale = false;
                        txtTimeInterval.Visible = false;
                        lblTimeInterval.Visible = false;
                        txtTimeInterval.Text = "60";
                        BindData();
                  }
}
            #endregion

Thanks
Troubleshooting check:

1) Can you put breakpoints when running?

2) Put a breakpoint in the Page_Load, and check the value of the controls to see if they are what you expect before anything else is done.  My guess is that they are fine, and something else later is messing it up

3) I create a small test with a single control, and a meta refresh, and after the post-back the state of the control was kept.

Bob
I tried but am loosing the viewstate info i think this is because the meta refresh doesn't cause a postback. Rather,it's a completely new page request.

neideas how to do this using javascript timer fn ?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found a solution....

setTimeout("Form1.submit()",30000);

works !

Thanks Bob