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 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";
        grid.DataBind();

But when i click filter i get error

enter image description here

share|improve this question
add comment

1 Answer 1

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=2.0.0.0, 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
show 6 more comments

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.