What's wrong with my custom sort method?

I'm going to have a page that contains many gridview controls. I'm trying to create a custom sort method for my GridView controls. I have an organic example that works just fine in my code.

        protected void myGridViewControl_Sorting(object sender, GridViewSortEventArgs e)
        {
            //PSUEDO CODE NOT WRITTEN FOR CORRECTNESS
            DataSet myDataSet = new DataSet();
            myDataSet  = myGridViewControl.Sort(someData, e.SortExpression).ToList();
        }

Open in new window


...and this works fine. So I try to then, I add another grid view control and use that grid's OnSorting method to pass the GridView control to my custom method. In essence, passing my grid and its GridViewSortEventArgs to my new global sorting method:

        protected void dtgClinicScheduledEvents1_Sorting(object sender, GridViewSortEventArgs e)
        {
            SortAllGrids(sender, e);
        }
.
.
.
        protected void SortAllGrids(object sender, GridViewSortEventArgs e)
        {
            GridView gridView = (GridView)sender;
            string strID = gridView.ID;

            myCustomCollection myLocalColletion= new
                               myCustomCollection().BinaryDeserialize(Session[mySessionVariable] as string);
            myLocalColletion.AccecptColletion = gridView.Sort(myLocalColletion.AccecptColletions, gridView.SortExpression).ToList();
            Session[mySessionVariable] = myLocalColletion.BinarySerialize();
        }

Open in new window



I'm getting a few errors in my custom sort method that I don't understand. If you can accept that the 1st line of code and the 3rd line of code (marked above with 1 and 3) are correct, then the compile time errors I'm getting are as follows:
  1. Now, my "myLocalColletion.AccecptColletions" object is telling me that the 1st parameter of the grid's sort method, needs to be a string? Why

2. My second parameter now is now expected to be a string. Why is it no longer a string, it was before in the "organic" Sorting method.

3. Lastly, the "." is error-ing out at compile time telling me that: "Operator "." cannot be applied to operand of type" void'". Again, this was not the case before, so why is it now?
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
 
Miguel OzConnect With a Mentor Software EngineerCommented:
Please change: (Notice e replaces gridView)
myLocalColletion.AccecptColletion = gridView.Sort(myLocalColletion.AccecptColletions, gridView.SortExpression).ToList();
with:
myLocalColletion.AccecptColletion = gridView.Sort(myLocalColletion.AccecptColletions, e.SortExpression).ToList();

Open in new window

If more help needed please provide more details about myCustomCollection() and what is the initial value of Session[mySessionVariable]
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.