Last post Oct 30, 2010 02:48 AM by pramesh1
Oct 29, 2010 07:57 PM|pramesh1|LINK
am having trouble figuring this one out.
Am using stored procedure and using databind for the gridview . i got the codes off other sites. I'm guessing its the code that i've underlined,
how or what do i use as the datasource for the sorting event. I used the Session for the paging event and that works but not for sorting.
any help would be appreciated.
protected void LoadComplaint()
gvComReport.DataSource = CompTypeStatusBLL.GetComplaint(ddlStatus.SelectedValue, ddlType.SelectedValue);
Session["MyDataSet"] = gvComReport.DataSource;
protected void gvComReport_Sorting(object sender, GridViewSortEventArgs e)
DataTable dtSortTable = Session["MyDataset"] as DataTable;
if (dtSortTable != null)
DataView dvSortedView = new DataView(dtSortTable);
dvSortedView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);
gvComReport.DataSource = dvSortedView;
private string ConvertSortDirectionToSql(SortDirection sortDirection)
string newSortDirection = String.Empty;
newSortDirection = "ASC";
newSortDirection = "DESC";
Oct 30, 2010 01:30 AM|p23ghodake|LINK
Your problem is not clear can you explain it, Use “try catch” and “debugger” in gvComReport_Sorting function to find the error. Then post it.
Mark as a Answer if it helps...!
Oct 30, 2010 02:48 AM|pramesh1|LINK
thanks for your response.
i was trying to get the sorting feature ffor the gridview.
i am getting the Session[MyDataSet] as null. i don;t know whether using Session is the correct way or not or if there is any other way i can get it working.
For now... i guess the problem is not knowing what i should as Datasource.