PS189 0 Newbie Poster

Hi,

am having trouble figuring this one out.

Am using stored procedure and using databind for the gridview . i got the codes off other sites.
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.
thanks

protected void LoadComplaint()
        {
           

            gvComReport.DataSource = CompTypeStatusBLL.GetComplaint(ddlStatus.SelectedValue, ddlType.SelectedValue);
            gvComReport.DataBind();
            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;
                gvComReport.DataBind();
            }


 private string ConvertSortDirectionToSql(SortDirection sortDirection)
        {
            string newSortDirection = String.Empty;

            switch (sortDirection)
            {
                case SortDirection.Ascending:
                    newSortDirection = "ASC";
                    break;

                case SortDirection.Descending:
                    newSortDirection = "DESC";
                    break;
            }

            return newSortDirection;
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.