DataGrid绑定到DataSet,然后绑定到DaTaview,GOT ERROR ... PLS HELP [英] DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP

查看:69
本文介绍了DataGrid绑定到DataSet,然后绑定到DaTaview,GOT ERROR ... PLS HELP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,在

过滤器之后将DataGrid与DataView / DataSet数据绑定...

我创建了以下过程,以便用户过滤尽可能多的数据

想要,但是下面的代码只允许用户第一次过滤,

当他们第二次尝试时,特定的施法错误信息会

提示一个....


我首先创建一个mydataset1,mydataset1数据源来自

DataGrid.DataSource。


然后我创建一个DataView以便我过滤....

我输入标准后,会在第一时间成功过滤,

但不是第二次。


我将DataGrid绑定到DataView一起......


第一个过滤器总是成功的,我只是不能过滤相同的数据

第二次......

我怀疑它是DataView和DataSet的问题,因为起初我绑定了

datagrid1并获取d ata data of datagrid1表格数据集,但最后

我将Datagird带到Dataview也.....所以有一些错误....我

想想....


我根本不知道如何将Datagrid与Dataview绑定,并允许用户

过滤他们想要的时间。 ....

有人可以指导我....这里是代码

尝试

Dim mydataset1作为新数据集

mydataset1 = DataGrid1.DataSource


Dim mydataview As New

DataView(mydataset1.Tables(Global.strTblName))

Dim strInput


strInput = InputBox(test)

mydataview.RowFilter =" Custno =" &安培; strInput& "


DataGrid1.Datasource = mydataview

''DataGrid1.DataSource = mydataset1

''DataGrid1.DataMember = GlobalDBExplorer.strTblName


Catch err As InvalidCastException

MsgBox(err.Message)

Catch err As Exception


MsgBox(错误消息)

结束尝试

解决方案

APK,


你只需要将数据视图绑定到你的数据网格。

没有更多的数据源。


我有我想你每次都在创建一个新的数据视图,并尝试将
绑定到你的数据网格上。


我希望这会有所帮助,


Cor


你好Cor,


我的第一个问题是......我没有一个修复数据集供我绑定

datagrid1 ....

它动态绑定到datasetA或datasetB ...取决于用户选择......


所以我必须创建anotehr本地数据集1并设置为

mydataset1 = datagrid.datasource
获得mydataset1后
,然后我创建Dataview ....

和用户允许对数据视图进行过滤,然后过滤后,然后

datagrid1绑定到dataview .....


请注意......我正在使用DataGrid = myDataView ....

所以对于其他的例子,我无法获取myDataSet1 = DataGrid.DataSource,

因为我不能简单地引用Dateset1 = DataView ..


所以我想知道DataView是怎么回事可以更新Dataset1 .....


如果我只允许创建一次数据视图,我可以知道应该在哪里

我创建DataView ?


" Cor Ligthert" <无************ @ planet.nl>在消息中写道

新闻:e5 ************** @ tk2msftngp13.phx.gbl ...

APK,

您只需要将数据视图绑定到数据网格。
没有更多的数据源。

我知道您每次创建新的数据视图时都会创建并尝试
将新的数据绑定到您的数据网格。

我希望这会有所帮助,





这样做,


dim myDataView = myDataTable.DefaultView;


如果您从表中获取DefaultView并使用您的条件对其进行过滤,那么当您更改数据视图中的值时,更改将通过

传递给基础数据表也是。

所以不需要再绑定它你可以评论这个


DataGrid1.Datasource = mydataview


希望这会有所帮助,

干杯,

Arun。
www.innasite.com


I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only allow user to filter the first time,
when they tried the second time, the speficied cast error message will
prompt one....

I create a mydataset1 first, and the mydataset1 data source was getting from
DataGrid.DataSource.

then I create a DataView in order for me to filter....
after I enter the criteria, then will filter successfully the first time,
but not second time.

the I bind the DataGrid to DataView together......

The first filter is always successfully, I just can not filter the same data
second time...
I suspect it the DataView and DataSet problem, because at first I bind
datagrid1 and get the data source of datagrid1 form Dataset, but at the end
I bing the Datagird to the Dataview also.....so there are some error....i
think....

I just have no idea how to bind the Datagrid with Dataview, and allow user
to filter as many time as they want.....
could someone pls guide me.... here are the CODE
Try
Dim mydataset1 As New DataSet
mydataset1 = DataGrid1.DataSource

Dim mydataview As New
DataView(mydataset1.Tables(Global.strTblName))
Dim strInput

strInput = InputBox("test")
mydataview.RowFilter = "Custno = " & strInput & ""

DataGrid1.Datasource= mydataview
'' DataGrid1.DataSource = mydataset1
'' DataGrid1.DataMember = GlobalDBExplorer.strTblName

Catch err As InvalidCastException
MsgBox(err.Message)
Catch err As Exception

MsgBox(err.Message)
End Try

解决方案

APK,

You only have to bind the dataview one time to your datagrid.
There cannot be more datasources.

I have the idea that you are creating everytime a new dataview and try to
bind that new one against your datagrid.

I hope this helps,

Cor


Hi Cor,

my first problem is that....I dun have a fix dataset for me to bind to
datagrid1....
It is dynamically bind to datasetA or datasetB...depend on user''s choice...

so I have to create anotehr local dataset1 and set to
mydataset1 = datagrid.datasource

after i get the mydataset1, then I create Dataview....
and user allow to do filter on dataview, then after the filtering, then
datagrid1 bind to dataview.....

please note that...I am using DataGrid = myDataView....
so for other feacture, i can not get the myDataSet1 = DataGrid.DataSource,
because i can not simply quote Dateset1 = DataView..

so I wish to know how the DataView can update the Dataset1.....

if I were to allow to create only one time dataview, may I know where should
I create the DataView ?


"Cor Ligthert" <no************@planet.nl> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...

APK,

You only have to bind the dataview one time to your datagrid.
There cannot be more datasources.

I have the idea that you are creating everytime a new dataview and try to
bind that new one against your datagrid.

I hope this helps,

Cor



Hi,
Do it like this,

dim myDataView = myDataTable.DefaultView;

If you take DefaultView from a table and filter it with your criteria,
when you change a values in the dataview the change will pass through
to the underlying datatable as well.
So no need to bind it once again you may comment this

DataGrid1.Datasource= mydataview

Hope this helps,
Cheers,
Arun.
www.innasite.com


这篇关于DataGrid绑定到DataSet,然后绑定到DaTaview,GOT ERROR ... PLS HELP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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