c# - Asp Net Gridview sort disapears when row edit -


when click on line update gridview sort of disappears , returns initial state. can be? below transcribe code:

  private string getsortdirection(string column)     {          // default, set sort direction ascending.         string sortdirection = "asc";          // retrieve last column sorted.         string sortexpression = viewstate["sortexpression"] string;          if (sortexpression != null)         {             // check if same column being sorted.             // otherwise, default value can returned.             if (sortexpression == column)             {                 string lastdirection = viewstate["sortdirection"] string;                 if ((lastdirection != null) && (lastdirection == "asc"))                 {                     sortdirection = "desc";                 }             }         }          // save new values in viewstate.         viewstate["sortdirection"] = sortdirection;         viewstate["sortexpression"] = column;          return sortdirection;     }      protected void gridviewlayoutproduto_sorting(object sender, gridviewsorteventargs e)     {         //retrieve table session object.         datatable dt = session["tasktable"] datatable;          if (dt != null)         {             //sort data.             dt.defaultview.sort = e.sortexpression + " " + getsortdirection(e.sortexpression);             session["tasktable"] = dt;             gridviewlayoutproduto.datasource = session["tasktable"];             gridviewlayoutproduto.databind();         }     }      protected void gridviewlayoutproduto_rowediting(object sender, gridviewediteventargs e)     {         gridviewlayoutproduto.editindex = e.neweditindex;         //checkbox alt = gridviewlayoutproduto.rows[e.neweditindex].findcontrol("checkbox1") checkbox;         //alt.enabled = false;         binddata();     }      protected void gridviewlayoutproduto_pageindexchanging(object sender, gridviewpageeventargs e)     {         gridviewlayoutproduto.pageindex = e.newpageindex;         gridviewlayoutproduto.databind();     }      protected void gridviewlayoutproduto_rowcancelingedit(object sender, gridviewcancelediteventargs e)     {         gridviewlayoutproduto.editindex = -1;         binddata();     }      private void binddata()     {         gridviewlayoutproduto.datasource = session["tasktable"];         gridviewlayoutproduto.databind();     } 

in session data datatable stored not organized, how can store in session datatble sort performed.

try putting line after sort of gridview

session["tasktable"] = ((dataview)gvprogramlar.datasource).totable(); 

hope helps you!


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -