473,473 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Search record in DataGrid

HS1
Hello all

I use a DataGrid to present the data of an Access database table ("Clients")
using DataAdapter and DataSet (ds)
-----------------------------------------------------------
DataGrid1.DataMember = "Clients"

DataGrid1.DataSource = ds

----------------------------------------------------------------------------
-------

I also have some button "Next". When I click in this button, I can go to the
next record in DataGrid1:
Private Sub NextButton_Click(......)

Me.BindingContext(DataGrid1.DataSource, "Clients").Position += 1
Now I have to create a button "Search". To do that I use a DataView as the
following code:
-----------------------------------------------------------------
Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SearchButton.Click

Dim cm As CurrencyManager

Dim dv As DataView = New DataView(ds.Tables("Clients"))

cm = CType(Me.BindingContext(dv), CurrencyManager)

DataGrid1.DataSource = dv

dv.Sort = "Name"

Dim int As Integer

int = dv.Find(Text_search.Text)

If int >= 0 Then

cm.Position = int

Else : MessageBox.Show(" Not Found ")

End If

End Sub

------------------------
It can be seen that when I use the search button, I change
DataGrid.DataSource from DataSet(ds) to DataView(dv). The problem here is
that after searching a record, when I click on "Next" button, I cannot go to
next record anymore event I set again the DataSource in the event hander of
this button:
Private Sub NextButton_Click(....)
DataGrid1.DataSource = ds
DataGrid1.DataMember = "Clients"

Do you know the best way to solve this problem

Thank you

Hoa


Nov 21 '05 #1
0 1108

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: serge calderara | last post by:
Dear all, I am using a datagrid which is populate from an array list items This array list can be updated at anytime.If this occurs I need that the content of the datagrid get synchronise too. ...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
0
by: jeffreycope | last post by:
Let's say I have a datagrid displaying data that's been filtered via a search page. Now I bring up a maintenance page and add a new record and this new record doesn't match the search / filter...
2
by: mattmerc | last post by:
Hi all, I've searched around on this topic but haven't come up with anything that matches exactly what I am trying to do. I have an ASP .net application running over a SQL database. I need to...
5
by: Alan | last post by:
I want search for a record in a table that a record's field value matching a particular value eg. customer name. What property or method of data binding manager or dataset on a form has this ?
2
by: HS1 | last post by:
Hello all I use a DataGrid to show the records of a table of an Access database (using a DataSet). Now I want to have a search button in the form so that when there is a match between my...
3
by: HS1 | last post by:
Hello To present (and manipulate) data in a table, I use an DataGrid and a DataSet "ds" DataGrid1.DataSource = ds However, to search a record in this DataGrid, I have to use DataView "dv" ...
0
by: Iain | last post by:
Hi All I have a datagrid which takes it's data from a table on a remote i-series. This datagrid is loaded on Page Load and the user is able to select a record to edit by pressing the...
2
by: preeti13 | last post by:
hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.