473,772 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_G OES_HERE)

Thanks,

-Dave
Nov 18 '05 #1
1 2231
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.param eters.add("@sea rch", txtSearch.text)

either way would work

--Michael
"RockNRoll" <da*******@yaho o.com> wrote in message news:ux******** ******@TK2MSFTN GP09.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_G OES_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
2440
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 columns, and adds a delete buttoncolumn and editcommandcolumn. Below that, I have several text boxes with a button with an onclick event to add new information to the database table the grid pulls from. A)Select Info binds fine.
0
4050
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 Class ExtendedSearchFieldValueColumnStyle Inherits DataGridTextBoxColumn Public WithEvents ColumnComboBox As ComboBox Public WithEvents ColumnTextBox As TextBox
2
304
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 . Based on this, I can updated the new value. My Problem is how can i get the value in the datagrid?
1
15751
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 columns to show some of the columns. Few of the columns have textboxes to make them available for editing. I am trying to update the dataset all at once using one update button. Here is my code... (for simplicity I have only listed one of the...
2
5675
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 itemtemplate. Datagrid is something like this- Category Week Amt Week% Button Revenue 1 100 Update Revenue 2 200 Update Cost 1 25 25
1
1870
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 columns to show some of the columns. Few of the columns have textboxes to make them available for editing. I am trying to update the dataset all at once using one update button. Here is my code... (for simplicity I have only listed one of the...
2
3399
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 want is to set the height of the row based on the number of lines in it. The row height of each row in the table may be different from each other. Is there a way to do this?
9
6095
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
6929
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, Grade.Midpoint, Grade.Maximum, Job.EEOCategoryCode, EEOCategory.Desc, Job.EEOSubCategoryCode, EEOSubCategory.Desc FROM Grade RIGHT JOIN (EEOSubCategory RIGHT JOIN (EEOCategory RIGHT JOIN Job ON EEOCategory.Code = Job.EEOCategoryCode) ON...
0
9620
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.