SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a webpart with SpGridView. I bind it with ObjectDataSource.

I want filtering multiple columns.

I set AllowFiltering for spgrid:

  grid.AllowFiltering = true;
  grid.FilterDataFields = ",Name,Region,Total Sales";
  grid.FilteredDataSourcePropertyName = "FilterExpression";
  grid.FilteredDataSourcePropertyFormat = "{1} = '{0}'";

and set ObjectDataSource

<asp:ObjectDataSource runat="server" ID="ds"  SelectMethod="GetTable"  ></asp:ObjectDataSource>

   ds.ObjectCreating += new ObjectDataSourceObjectEventHandler(ds_ObjectCreating);
  void ds_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        myDataTable = new DataTableWrapper(sourceDataTable);

        e.ObjectInstance = myDataTable;

     sourceDataTable = list.GetItems(quary).GetDataTable();
        myDataTable = new DataTableWrapper(sourceDataTable);
        Type t = myDataTable.GetType();
        ds.TypeName = t.AssemblyQualifiedName;

        grid.DataSourceID = "ds";

But when i click filter i get error

enter image description here

share|improve this question

ObjectDatasource takes the TypeName of your data source, not the Qualified name. You need to modify this

Type t = myDataTable.GetType();
    ds.TypeName = t.AssemblyQualifiedName;

so you set the TypeName property to the type name for example "My.ObjectDataSource.NorthwindData" instead of "My.ObjectDataSource.NorthwindData, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e08"

share|improve this answer
I don't underestand. :( – ar.gorgin Aug 7 '12 at 5:11
Reading you error message again, I think i understand that it works the first time, but as soon as you click on filter it throws an error. You error message says that you have not set the TypeName property when you click. So i believe that your problem is that when you do postbacks for your grid your not handling the setting of the TypeName again. – Robban1980 Aug 7 '12 at 13:08
in load i set setting of the TypeName but don't word and get error. – ar.gorgin Aug 8 '12 at 7:50
I don't understand the last part of your message "but don't word and get error"? – Robban1980 Aug 8 '12 at 7:56
Sorry, I have the wrong type."don't work and get error" – ar.gorgin Aug 9 '12 at 3:33

Your Answer


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.