Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have written the following code

DataView dv = (DataView)ObjectDataSource1.Select(); 
                GridView1.DataSourceID = null;                
                dv.RowFilter = @"ElementDescription like '%"+searchbox.Text.Trim()+"%'";
                dv.Sort = "ElementDescription DESC";
                //dv.RowStateFilter = DataViewRowState.ModifiedCurrent;               
                GridView1.DataSource = dv;         
                source = "view";
                GridView1.DataBind();

I am able to get this working until sorting on the gridview is clicked once gridview sort is clicked i get the error " datasource doesnot support sorting"

I you have any ideas kindly let me know.
Posted
Updated 26-Oct-10 16:39pm
v2

When you click sort, in your click event clear the datasourceID.
Try, Gridview.Columns.Clear() then rebind everything.

Have a look at this thread discussion [^]for more option and details.
 
Share this answer
 
i wasted nearly morethan a day figuring out how to convert dataview to objectdatasource and finally

i could not do the search by using dataview so i created a new stored procedure and then changed the select method on search button clicked event ,Below is the code


SQL
ObjectDataSource1.SelectMethod = "GetDataBySearch";
        source = "view";
        ViewState["searchitem"] = searchbox.Text.Trim();
        ViewState["dropdownindex"] = Convert.ToInt32(DropDownList1.SelectedValue);
        ObjectDataSource1.Selecting +=new ObjectDataSourceSelectingEventHandler(ObjectDataSource1_Selecting);
        GridView1.DataBind();



hope if it helps someone
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900