473,385 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Find in DataGridView

13
Hi people,

with this command I can get the row index of founded records:
i = dv.Find(txtFind.Text);
but is there a good method that lets me show only founded records in DataGridView?

Or is it correct to clear the DataSet, to query database and to fill DataSet with search result??? (I tried it and it works!)

Thanx
Jul 11 '07 #1
4 2251
havana7
13
What is the best way to search in a DataSet and show results???
DataView.Find or to query DB and to fill DataSet?
Thanx
Jul 12 '07 #2
Vidhura
99
What is the best way to search in a DataSet and show results???
DataView.Find or to query DB and to fill DataSet?
Thanx
Use bindingsource
BindingSource bs= new BindingSource(dataset, "table");
dataGridview1.datasource=bs;


To filter the records
bindingSourceRoute.Filter ="ID=20";

Bind it again with datagridView
dataGridview1.datasource=bs;
this.dataGridview1.Update();
Jul 12 '07 #3
radcaesar
759 Expert 512MB
What is the best way to search in a DataSet and show results???
DataView.Find or to query DB and to fill DataSet?
Thanx

Here is the best and fast one

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnSearch.Click

'Create and fill the dataset
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath(".") & "\..\Xml\PartList.xml")

'Set a primary Key
ds.Tables(0).PrimaryKey = New DataColumn() {ds.Tables(0).Columns("partid")}

'Create a datarow collection
Dim drCollection As DataRow()

'Use the tables.select command and pass in your search criteria
drCollection = ds.Tables(0).Select("manufacturer = '" _
& Replace(txtSearch.Text, "'", "''") & "'")


'Display results by looping through datarow collection
Dim dr As DataRow
lblResults.Text = ""
For Each dr In drCollection
lblResults.Text = lblResults.Text & dr.Item("partid").ToString & ","
Next

'Dispose item
ds.Dispose()
End Sub
Jul 12 '07 #4
havana7
13
Use bindingsource
BindingSource bs= new BindingSource(dataset, "table");
dataGridview1.datasource=bs;


To filter the records
bindingSourceRoute.Filter ="ID=20";

Bind it again with datagridView
dataGridview1.datasource=bs;
this.dataGridview1.Update();
I like very much this solution, thanx to everybody!!!
Jul 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Peter | last post by:
How do I do Search in DataGridView and make the found row visible in UI? Thanks Peter
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
3
by: Lars E. Nes | last post by:
Hi all. I would like to automaticly select a item in a datagridview using the value of column. I do not have the index. Just the value (which is a string). How can this be done? Thanks.
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
5
by: Rainer Queck | last post by:
Hello NG, what would be the best way to locate a DataRrow in a DataGridView? I have by DataTable.Select a bunch of DataRows from a DataTable (which is the data source to the DataGridView). Now...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
2
by: sajjeelhassan | last post by:
hi can any one tell i found a problem ...while during work on datagridview checkbox is in the 2nd column of the datagridview having header "REGISTER" and a textbox in the 1st column of the...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.