Welcome, Guest. Please login or register.
Did you miss your activation email?
dotNETprogrammers.net/forum :: A community for .NET developers « Javaforums.net .NET programming boards (modify) « ASP.NET «  (Moderator: OutRunner)Topic: refresh/reload a gridview using page.IsPostBack()
Pages: [1]   Go Down
  Print  
Author Topic: refresh/reload a gridview using page.IsPostBack()  (Read 3221 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« on: February 16, 2009, 07:26:38 PM »

Took me some time to figure out how to refresh/reload a page so i decided to do it with some javascript. Not the most elegant solution but it works, if you know how to write a cleaner solution let me know.

Code
GeSHi (csharp):
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10.  
  11. public partial class _Default : System.Web.UI.Page
  12. {
  13.    protected void Page_Load(object sender, EventArgs e)
  14.    {
  15.        //PersoonDataSetTableAdapters.PersonenTableAdapter Adapter = null;
  16.        //Adapter = new PersoonDataSetTableAdapters.PersonenTableAdapter();
  17.       // GridView1.DataSource = null;
  18.  
  19.        if (Page.IsPostBack)
  20.        {
  21.            //GridView1.DataSource = Adapter.GetPersoon();
  22.            //GridView1.DataBind();
  23.            Label1.Text = "postback? " + Page.IsPostBack;
  24.  
  25.            string scriptString = "<script language=JavaScript>window.location.href=window.location.href </script>";
  26.            if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptString))
  27.            {
  28.                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script", scriptString);
  29.            }
  30.        }
  31.  
  32.        if (!Page.IsPostBack)
  33.        {
  34.          //  GridView1.DataSource = Adapter.GetPersoon();
  35.          //  GridView1.DataBind();
  36.            Label1.Text = "postback? " + Page.IsPostBack;    
  37.        }
  38.    }  
  39. }
  40.  
Created by GeSHI 1.0.7.20
« Last Edit: February 16, 2009, 07:30:59 PM by HappyFace » Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
jurka
Staff
Member
*
*

Reputation: 5
Offline Offline
Posts: 188
Referrals: 0

Awards
« Reply #1 on: February 17, 2009, 07:13:07 AM »

Isn't there something in .net like in php is header() function. Or the other not elegant solution is to use meta tags.
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« Reply #2 on: February 17, 2009, 05:13:03 PM »

Isn't there something in .net like in php is header() function. Or the other not elegant solution is to use meta tags.

Not that i know of, if i would i wouldn't have written the code above I'm not sure about meta tags, haven't used them enough to be comfortable with it.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Pages: [1]   Go Up
  Print  
dotNETprogrammers.net/forum :: A community for .NET developers « Javaforums.net .NET programming boards (modify) « ASP.NET «  (Moderator: OutRunner)Topic: refresh/reload a gridview using page.IsPostBack()
 
Jump to:  

Your Ad Here