Private void bindgrid () {teacher.bll.admin.classbll bar = new teacher.bll.admin.classbll (); dataview dv = strl.getbclassDataSet (). Tables [0] .defaultView; if (ViewState ["strsort"] ! = null) {DV.Sort = ViewState ["strsort"]. TOSTRING ();} if (ViewState ["strrowfilter"]! = null) {dv.rowfilter = viewState ["strrowfilter"]. Tostring ();} DataGrid1.datasource = DV; DataGrid1.DATABIND ();
private void DataGrid1_SortCommand (object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e) {string strSort = "";. foreach (DataGridColumn oCol in DataGrid1.Columns) {if (e.SortExpression.ToLower () CompareTo (oCol.SortExpression .Tolower ()) == 0) {Ocol.Headertext = Ocol.Headertext.Replace ("(↑)", ""). Replace ("()", ""); if (e.Sortexpression.indexof) "ASC")> 1) {ocol.sortexpression = E.Sortexpression.Replace ("ASC", "DESC"); OCOL.HEADERTEXT = OCOL.HEADERTEXT "(↓)"; strsort = Ocol.sortexpression;} else (E.Sortexpression.indexof ("DESC")> 1) {Ocol.Sortexpression = E.Sortexpression.replace ("DESC", ""); strsort = e.Sortexpression;} else {ocol.sortexpression = E.Sortexpression "ASC"; ocol.Headertext = OCOL.HEADERTEXT "(↑)"; strsort = ocol.sortexpression;}}}
// This is the sorting field of sort to be saved ViewState ["strsort"] = strsort;
// Bind DataGrid BindGrid ();