将dataview转换为objectdatasource是否有可能??? [英] convert dataview to objectdatasource is it possible???

查看:153
本文介绍了将dataview转换为objectdatasource是否有可能???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了以下代码

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();


在单击gridview排序后,单击GridView上的排序之前,我一直可以正常工作,但出现错误数据源不支持排序".

我有任何想法要让我知道.


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.

推荐答案

单击排序"时,在单击事件中清除datasourceID.
尝试Gridview.Columns.Clear() ,然后重新绑定所有内容.

看看此主题讨论 [
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.


我浪费了几乎一天以上的时间弄清楚如何将dataview转换为objectdatasource,最后

我无法使用dataview进行搜索,因此我创建了一个新的存储过程,然后更改了搜索按钮clicked事件的选择方法,下面是代码


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


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


这篇关于将dataview转换为objectdatasource是否有可能???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆