1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// code coupé instanciation de l'objet liste
grdListeProjet.DataSource = liste;
Session["TableTrie"] = grdListeProjet.DataSource;
grdListeProjet.DataKeyNames = new string[] { "Id" };
grdListeProjet.DataBind();
}
}
protected void grdListeProjet_OnSorting(object sender, GridViewSortEventArgs e)
{
// dataTable reste toujours à null.
// Le code ne passe donc pas dans le "If"
DataTable dataTable = Session["TableTrie"] as DataTable;
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.Sort = e.SortExpression + " ASC";
grdListeProjet.DataSource = dataView;
grdListeProjet.DataBind();
}
} |