Stuck at Sorting in ASP.Net?

dy/dx = (X^2+1)

New member
private void DataGrid1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string sortExpression = (string)Session["SortExp"];
string sortDirection = (string)Session["SortDir"];

if(sortExpression != e.SortExpression)
{
sortExpression = e.SortExpression;
sortDirection = "asc";
}
else
{
if(sortDirection == "asc")
sortDirection = "desc";
else
sortDirection = "asc";
}

Session["SortExp"] = sortExpression;
Session["SortDir"] = sortDirection;
BindDataGrid(sortExpression + " " + sortDirection);
}
 
I am displaying the data using pages in Gridview. Whenever we move to the next page, I bind the data. After sorting, while moving to the next page. The data on the next page is not properly displaying. What may be the reasons?
 
private void DataGrid1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
string sortExpression = (string)Session["SortExp"];
string sortDirection = (string)Session["SortDir"];

if(sortExpression != e.SortExpression)
{
sortExpression = e.SortExpression;
sortDirection = "asc";
}
else
{
if(sortDirection == "asc")
sortDirection = "desc";
else
sortDirection = "asc";
}

Session["SortExp"] = sortExpression;
Session["SortDir"] = sortDirection;
BindDataGrid(sortExpression + " " + sortDirection);
}
 
Back
Top