protected void GVinsurance_onSorting(object sender, GridViewSortEventArgs e)
{
DataTable dt1 = (DataTable)ViewState["DT"];//GVProvider.DataSource as DataTable;
if (dt1 != null)
{
if (dt1 != null)
{
DataView dvSortedView = new DataView(dt1);
dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection);
GVInsurance.DataSource = dvSortedView;
GVInsurance.DataBind();
}
}
}
----------------------------------------
private string getSortDirectionString(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
if (Convert.ToString(ViewState["newSortDirection"]) == "DESC")
{
ViewState["newSortDirection"] = "ASC";
}
else
ViewState["newSortDirection"] = "DESC";
return newSortDirection = Convert.ToString(ViewState["newSortDirection"]);
}
{
DataTable dt1 = (DataTable)ViewState["DT"];//GVProvider.DataSource as DataTable;
if (dt1 != null)
{
if (dt1 != null)
{
DataView dvSortedView = new DataView(dt1);
dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection);
GVInsurance.DataSource = dvSortedView;
GVInsurance.DataBind();
}
}
}
----------------------------------------
private string getSortDirectionString(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
if (Convert.ToString(ViewState["newSortDirection"]) == "DESC")
{
ViewState["newSortDirection"] = "ASC";
}
else
ViewState["newSortDirection"] = "DESC";
return newSortDirection = Convert.ToString(ViewState["newSortDirection"]);
}
Thank you Manju sir for posting this good one. Keep posting !!!
ReplyDelete