Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SpGridView whit BoundFiled. I set a ObjectDataSource for it.

        sourceDataTable = new DataTable ();
        myDataTable = new DataTableWrapper(sourceDataTable);
        Type t = myDataTable.GetType();

        ObjectDataSource ds = new ObjectDataSource();
        ds.TypeName = t.AssemblyQualifiedName;
        ds.EnableViewState = false;
        ds.ID = "myDataSource";
        ds.SelectMethod = "GetTable";
        ds.ObjectCreating += new ObjectDataSourceObjectEventHandler(ds_ObjectCreating);
       this.Controls.Add(ds);

I created a DataTable with 3 columns. I fill it with name,number. and set for sourceDataTable.

When i sort SpGridView, name column sorting but number column don't sort.

I convert Number to string but don't sort.

share|improve this question

1 Answer 1

It is difficult to troubleshoot since you didn't post all the code...

I would make sure your BoundField is setup correctly and the SortExpresssion property is being set to the correct column in your DataTable:

BoundField column = new BoundField();
column.DataField = name;
column.SortExpression = name;
column.HeaderText = name;

If that doesn't work, read Erik's wonderful blog post: Building A SPGridView Control – Part 1: Introducing the SPGridView.

share|improve this answer
    
I use this code and set sortexpression for all column, but don't work. –  ar.gorgin May 15 '12 at 3:39
    
Did you read the link I posted? Or, can you post the rest of our code? –  Kit Menke May 15 '12 at 13:36
    
Yes, i use this link. –  ar.gorgin May 15 '12 at 16:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.