Ejemplo n.º 1
0
        protected void GridViewUserPolicies_Sorting(object sender, GridViewSortEventArgs e)
        {
            DataTable datatable = (DataTable)ViewState["table"];

            if (datatable != null)
            {
                DataView view = new DataView(datatable);
                if (Convert.ToString(ViewState["sort"]).Contains("ASC") || Convert.ToString(ViewState["sort"]) == "")
                {
                    view.Sort         = e.SortExpression + " " + "DESC";
                    ViewState["sort"] = view.Sort.ToString();
                }
                else
                {
                    view.Sort         = e.SortExpression + " " + "ASC";
                    ViewState["sort"] = view.Sort.ToString();
                }
                GridViewUserPolicies.DataSource = view;
                GridViewUserPolicies.DataBind();
            }
        }
Ejemplo n.º 2
0
 public void bindGrid()
 {
     try
     {
         SqlCommand listPolicies = new SqlCommand("spListOfPolicies", connection);
         listPolicies.CommandType = CommandType.StoredProcedure;
         connection.Open();
         SqlDataAdapter sda = new SqlDataAdapter(listPolicies);
         DataTable      dt  = new DataTable();
         sda.Fill(dt);
         ViewState["VSTable"]            = dt;
         GridViewUserPolicies.DataSource = dt;
         GridViewUserPolicies.DataBind();
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         connection.Close();
     }
 }