473,404 Members | 2,137 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,404 software developers and data experts.

Easy one - How do I filter a datagrid based on textbox value?

I'm new to ASP.NET and need to filter a datagrid based on a textbox value.

I have a working datagrid and would like the WHERE part of my SQL statement
to call the value of a textbox and refresh the datagrid when a button is
clicked.

SELECT RateMatrix.Name, RateMatrix.[Labor Class], RateMatrix.EC,
RateMatrix.[TM Rate], RateMatrix.[Bus Unit] FROM RateMatrix WHERE
([RateMatrix].[TM Rate] <= TEXTBOX_VALUE_GOES_HERE)

Thanks,

-Dave
Nov 18 '05 #1
1 2211
Depending on the size of ALL the data you could possibly display, one option is to load all the data into a DataTable, and then create a DataView with a rowfilter set to filter out just the rows you want, then bind the view to the DataSet. You could then persist the data in the session so you don't need to go back to the database each time.

Or, and probably easiest is to modify your sql statement to use a parameter
SELECT RateMatrix.Name, RateMatrix.[Labor Class], RateMatrix.EC,
RateMatrix.[TM Rate], RateMatrix.[Bus Unit] FROM RateMatrix WHERE
([RateMatrix].[TM Rate] <= @search)
after you load this sql statement into a command object, add this
myCommand.parameters.add("@search", txtSearch.text)

either way would work

--Michael
"RockNRoll" <da*******@yahoo.com> wrote in message news:ux**************@TK2MSFTNGP09.phx.gbl... I'm new to ASP.NET and need to filter a datagrid based on a textbox value.

I have a working datagrid and would like the WHERE part of my SQL statement
to call the value of a textbox and refresh the datagrid when a button is
clicked.

SELECT RateMatrix.Name, RateMatrix.[Labor Class], RateMatrix.EC,
RateMatrix.[TM Rate], RateMatrix.[Bus Unit] FROM RateMatrix WHERE
([RateMatrix].[TM Rate] <= TEXTBOX_VALUE_GOES_HERE)

Thanks,

-Dave

Nov 18 '05 #2

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

Similar topics

0
by: lu | last post by:
I have a page with datagrid (for viewing, delete,edit,update) and text fields with button to add info to database. When user comes to page the datagrid selects info from database, binds in...
0
by: Faith | last post by:
I found code on www.codeproject.com. Here is a sample it is called DataGridColumnDropDown. I modified it to use the text box when I wanted it to depended on a certain search criteria. Public...
2
by: VIJAY KUMAR | last post by:
Hi, I Have a values in a datagrid. I want to edit the values in a datagrid (Say Company="Techgene" which is primary key). Before Update the selected Record I have to get the Orignal VAlue ....
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
2
by: Tor Inge Rislaa | last post by:
How to change row height in a DataGrid I have DataGrid that is filled with data from a table in a DataSet. The content of the cells is text of more than one line (as a note field). What I...
9
by: dee | last post by:
I'd like to filter by the following criteria: left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767 I have no idea how to do this. Appreciate help.
94
by: mlcampeau | last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries. MY - JobVacancyJobs SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum,...
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: 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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.