By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

Search in DataGrid

P: n/a
My DataGrid is bound to DataSet which contains relationship between two
tables as follows:

SqlHelper.FillDataset(strConn, CommandType.StoredProcedure,
"spSelectClientApplicant", ds, New String() {"Client", "Applicant"})

ds.Relations.Add("Applicants", ds.Tables("Client").Columns("Client_ID"),
ds.Tables("Applicant").Columns("Client_ID"))

grdDetails.DataSource = ds.Tables("Client").DefaultView

My form provides three search criteria Client ID, Applicant First Name,
Applicant Last Name. Now my problem is how can I implement search capability
for the DataGrid. I want my search to look for records for the provided
Client ID or do a wildcard character search for provided Applicant First
Name, Last Name.

Thanks

Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Depends on where you want the search to happen, which will also depend on
how much data you're talking about.

You can either set up your stored procedure to perform the search, in which
case it will need to take in the parameters for the search, or you can use a
DataView to filter records that you have already received (and the stored
procedure would just return all records).

I would only use the latter if you know that there will not be very much
data; I think you're probably better off making your stored procedure
perform the search.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Job Lot" <Jo****@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
My DataGrid is bound to DataSet which contains relationship between two
tables as follows:

SqlHelper.FillDataset(strConn, CommandType.StoredProcedure,
"spSelectClientApplicant", ds, New String() {"Client", "Applicant"})

ds.Relations.Add("Applicants", ds.Tables("Client").Columns("Client_ID"),
ds.Tables("Applicant").Columns("Client_ID"))

grdDetails.DataSource = ds.Tables("Client").DefaultView

My form provides three search criteria Client ID, Applicant First Name,
Applicant Last Name. Now my problem is how can I implement search
capability
for the DataGrid. I want my search to look for records for the provided
Client ID or do a wildcard character search for provided Applicant First
Name, Last Name.

Thanks

Jul 21 '05 #2

P: n/a
hi job,

You can do a search for the data by searching the dataset that is used to
bind to the grid.
You can use the following syntax to get the rows that match a certain
criteria fromthe dataset.

dataset myDS = new dataset(.......);
myDS.select("FirstName = '" + nameSearch + "'");

Wild card character searches can also be performed with similar syntax as
SQL LIKE.

nyDS.Select("FirstName LIKE 'A%'");

Hope the above explanation helps you,
Kannan.V
http://kannanv.blogspot.com

"Job Lot" wrote:
My DataGrid is bound to DataSet which contains relationship between two
tables as follows:

SqlHelper.FillDataset(strConn, CommandType.StoredProcedure,
"spSelectClientApplicant", ds, New String() {"Client", "Applicant"})

ds.Relations.Add("Applicants", ds.Tables("Client").Columns("Client_ID"),
ds.Tables("Applicant").Columns("Client_ID"))

grdDetails.DataSource = ds.Tables("Client").DefaultView

My form provides three search criteria Client ID, Applicant First Name,
Applicant Last Name. Now my problem is how can I implement search capability
for the DataGrid. I want my search to look for records for the provided
Client ID or do a wildcard character search for provided Applicant First
Name, Last Name.

Thanks

Jul 21 '05 #3

P: n/a
Hi

To start with there no Select method for DataSet.

Secondly, I am showing master detail records in my DataGrid using DataSet's
Relation object. Client_ID is part of master DataTable and FirstName,
LastName are part of detailed DataTable. How would i filter my records based
on detailed DataTable

"Kannan.V" wrote:
hi job,

You can do a search for the data by searching the dataset that is used to
bind to the grid.
You can use the following syntax to get the rows that match a certain
criteria fromthe dataset.

dataset myDS = new dataset(.......);
myDS.select("FirstName = '" + nameSearch + "'");

Wild card character searches can also be performed with similar syntax as
SQL LIKE.

nyDS.Select("FirstName LIKE 'A%'");

Hope the above explanation helps you,
Kannan.V
http://kannanv.blogspot.com

"Job Lot" wrote:
My DataGrid is bound to DataSet which contains relationship between two
tables as follows:

SqlHelper.FillDataset(strConn, CommandType.StoredProcedure,
"spSelectClientApplicant", ds, New String() {"Client", "Applicant"})

ds.Relations.Add("Applicants", ds.Tables("Client").Columns("Client_ID"),
ds.Tables("Applicant").Columns("Client_ID"))

grdDetails.DataSource = ds.Tables("Client").DefaultView

My form provides three search criteria Client ID, Applicant First Name,
Applicant Last Name. Now my problem is how can I implement search capability
for the DataGrid. I want my search to look for records for the provided
Client ID or do a wildcard character search for provided Applicant First
Name, Last Name.

Thanks

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.