Search in DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
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
 
Back
Top