473,395 Members | 1,541 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,395 software developers and data experts.

Searchable DataGrid

I am trying to implement searchable DataGrid. I am creating a DataSet object with DataRelation on form load, as follows:

Private Sub BindDataGrid()
Dim planTS As New DataGridTableStyle
Dim appTS As New DataGridTableStyle

Try
'Call ExecuteDataset static method of SqlHelper class that returns a Dataset.
myDS = SqlHelper.ExecuteDataset(strConn, CommandType.StoredProcedure, "spSearchPlanDetails")

'Create relation.
myDS.Relations.Add("Applicants", myDS.Tables(0).Columns("Client_ID"), myDS.Tables(1).Columns("Client_ID"), False)

'Set mapping name for planTS.
planTS.MappingName = "Table"
planTS.AllowSorting = False

Dim myCOL As New DataGridTextBoxColumn
With myCOL
.MappingName = "Plan_ID"
.HeaderText = "Plan_ID"
End With
planTS.GridColumnStyles.Add(myCOL)

myCOL = New DataGridTextBoxColumn
With myCOL
.MappingName = "Client_ID"
.HeaderText = "Client ID"
End With
planTS.GridColumnStyles.Add(myCOL)

myCOL = New DataGridTextBoxColumn
With myCOL
.MappingName = "PlanDate"
.HeaderText = "Plan Date"
.Format = "dd/MM/yyyy"
End With
planTS.GridColumnStyles.Add(myCOL)

'Set mapping name for appTS.
appTS.MappingName = "Table1"
appTS.AllowSorting = False

myCOL = New DataGridTextBoxColumn
With myCOL
.MappingName = "Client_ID"
.HeaderText = "Client_ID"
.Width = 0
End With
appTS.GridColumnStyles.Add(myCOL)

myCOL = New DataGridTextBoxColumn
With myCOL
.MappingName = "FirstName"
.HeaderText = "First Name"
End With
appTS.GridColumnStyles.Add(myCOL)

myCOL = New DataGridTextBoxColumn
With myCOL
.MappingName = "LastName"
.HeaderText = "Last Name"
End With
appTS.GridColumnStyles.Add(myCOL)

'Add planTS to the DataGrid.
grdDetails.TableStyles.Add(planTS)

'Add appTS to the DataGrid.
grdDetails.TableStyles.Add(appTS)

Catch ex As SqlException
Throw ex
End Try
End Sub

Here’s the code for spSearchPlanDetails stored proc:

CREATE PROCEDURE spSearchPlanDetails
AS
SELECT Plan_ID, Client_ID, PlanDate
FROM Plans

SELECT P.Client_ID, A.FirstName, A.LastName
FROM Plans P, Applicants A
WHERE P.Client_ID = A.Client_ID
GO

Now, I have three search criteria’s on my Form, Client_ID, FirstName and LastName. On click on Search button I am trying to show data in the DataGrid which matches the search criteria as follows:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
myDS.Tables(0).DefaultView.RowFilter = "Client_ID = " & txtClientID.Text & " AND FirstName LIKE '" & txtFirstName.Text & "%'" & " AND LastName LIKE '" & txtLastName.Text & "%'"

'Bind DataGrid.
grdDetails.DataSource = myDS.Tables(0).DefaultView
End Sub

But, I am getting an error saying "Cannot find column [FirstName]". Does anyone knows what it could be?

Thanx
Jul 21 '05 #1
3 1337
Hi Job,

It is not the most easiest one, when everything is working, than I ask
myself why is he using in the select datatable(0) while the information is
as I suspect in datatable(1).

However a real gues

Cor
Jul 21 '05 #2
A Client can have more than one applicants. Applicants have firstname and lastname. I want to show Parent/Child relationship in my DataGrid. Table(0) holds info about parent and Table(1) holds info abt child rows.

"Cor Ligthert" wrote:
Hi Job,

It is not the most easiest one, when everything is working, than I ask
myself why is he using in the select datatable(0) while the information is
as I suspect in datatable(1).

However a real gues

Cor

Jul 21 '05 #3
Hi Job,

What is the question, how you can do your application or how it is possible
that you have an error?

On the first question I have no other answer than start with a more simple
solution. An answer on this goes far to far for a newsgroup in my opinion
seeing the problems/solution you have now. On the other one I thought I have
given you an answer, I assume that the items are in table1 and not in table
0 that you try to select based on the items.

Sorry, I can not think about an other answer that I can give you.

Cor

A Client can have more than one applicants. Applicants have firstname and lastname. I want to show Parent/Child relationship in my DataGrid. Table(0)
holds info about parent and Table(1) holds info abt child rows.
"Cor Ligthert" wrote:
Hi Job,

It is not the most easiest one, when everything is working, than I ask
myself why is he using in the select datatable(0) while the information is as I suspect in datatable(1).

However a real gues

Cor

Jul 21 '05 #4

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

Similar topics

6
by: Alexandre Plennevaux | last post by:
hello mates, my question is such: should i turn a 80 pages doc file into a database so that: - i can make it searchable through an online form - it can be modified and every modification...
5
by: PR | last post by:
Searchable product images + prices database? What system should I use to put a database on the WEB which shows images and allows searches, including searches within given price ranges for...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
by: Vadim | last post by:
How To Make Searchable Combobox in ASP.NET? For example: When start typing R it has to show first item starting with 'R' if continue Ro it has to show items starting with 'Ro' How to...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
3
by: Job Lot | last post by:
I am trying to implement searchable DataGrid. I am creating a DataSet object with DataRelation on form load, as follows: Private Sub BindDataGrid() Dim planTS As New DataGridTableStyle Dim appTS...
3
by: Bhadan | last post by:
This is a beginner question: I wish to make a textbox searchable for strings. Is this possible with a property of the textbox, or do I have to wright a method. TIA. Bhads.
5
by: just another hacker | last post by:
Word Up Friends ~ I wuz after an online copy of K&R C book... found me a pdf, but it's only got scanned text. Can ppl suggest a url with fully searchable text of the book? Thanx M8S.
21
by: Pieter | last post by:
Hi, I need some type of array/list/... In which I can store objects together with a unique key. The most important thing is performance: I will need to do the whole time searches in the list of...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.