Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loop The Loop
Message
 
 
À
29/07/2010 15:27:14
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01474505
Message ID:
01474506
Vues:
32
Did you intend to call SortGrid() only on the initial Load of the page?

>Hi,
>
>I think I am still having a problem with understanding when things happen in a web page. I am not sure if this is a MM.NET thing or a web development thing.
>
>I have an ASPX page with some text boxes for entering search criteria, a button to search and a gridview to display the results. The grid view allows the user to sort the grid by clicking on the header of some columns. This works fine.
>
>The problem is that I now want the grid to default to a particular order if the user hasn't already set an order. So I check if the Session["SortExpression"] exists, if it does I set the order to that, otherwise I set it to my default order. Now, the user can select one of the items in the grid and this displays a new page for editing the selected item. When this second page is closed by the user pressing the Save or Cancel button, the search page gets displayed again. But the grid is not ordered at all. I've stepped through the code and my SortGrid method does get called and the correct order set, but then when the page actually gets displayed the grid is in no particular order.
>
>My code is like this:
>
>
        protected void Page_Load(object sender, EventArgs e)
>        {
>            Session["PolicyPK"] = null; 
>            this.oPolicy = (Policy)this.RegisterBizObj(new Policy());
>
>            if (IsPostBack == false)
>            {
>                this.GetData();
>                this.SortGrid();
>            }
>            this.calIssueDate.Visible = false;
>
>
>            this.SetFocus(this.txtPolicyNumber);
>        }
>
>        private void SortGrid()
>        {
>            if (Session["Policy"] != null)
>            //if (this.oPolicy.GetRowCount() != 0)
>            {
>                if (Session["SortOrder"] != null && Session["SortExpression"] != null)
>                {
>                    // the following method automatically switches between ascending and descending so pass in the wrong sort direction to fool it
>                    Session["SortOrder"] = (string)Session["SortOrder"] == "ASC" ? "DESC" : "ASC";
>                    this.grdList.Sort((string)Session["SortExpression"], SortDirection.Ascending);
>                }
>                else
>                    this.grdList.Sort("PolicyNumber", SortDirection.Ascending);
>            }
>        }
>
>Any ideas what is going on here?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform