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

How to select a gridviewrow based on textbox value

So basically I have a gridview that is selectable. Below it I have a dropdownlist and a textbox. The dropdownlist has the options for each column in the row(I am using an ajax autocomplete extender that checks for related values in the textbox based of which dropdownlist value is selected.) I want to take that a step further and see if I can select a row based on what is in the textbox on the textchanged event. Right now im playing around with using a datatable and then filling a string[] of whatever column the dropdownlist is selected on. And then im thinking about using something that will check the string array and select the first gridview row based on what is in the textbox. Am I going about this the right way? This is what I have so far.
Expand|Select|Wrap|Line Numbers
  1. protected void txtFilter_TextChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         DataTable dt;
  5.         SqlCommand cmd = new SqlCommand("SELECT * FROM General", csbg2);
  6.         SqlDataAdapter da = new SqlDataAdapter(cmd);
  7.  
  8.  
  9.         dt = fillDatatable(cmd, da);
  10.  
  11.         string[] items = new string[dt.Rows.Count];
  12.  
  13.         switch (ddlEducation.SelectedValue)
  14.         {
  15.             case "SSN":
  16.                 int i = 0;
  17.                 foreach (DataRow dr in dt.Rows)
  18.                 {
  19.                     items.SetValue(dr["SSN"].ToString(), i);
  20.                     i++;
  21.                 }
  22.             case "FName":
  23.                 int i = 0;
  24.                 foreach (DataRow dr in dt.Rows)
  25.                 {
  26.                     items.SetValue(dr["FName"].ToString(), i);
  27.                     i++;
  28.                 }
  29.             case "LName":
  30.                 int i = 0;
  31.                 foreach (DataRow dr in dt.Rows)
  32.                 {
  33.                     items.SetValue(dr["LName"].ToString(), i);
  34.                     i++;
  35.                 }
  36.  
  37.  
  38.  
  39.         }//end switch
  40.  
  41.  
  42.     }// end txtfilter_TextChanged
  43.  
May 20 '10 #1
1 1900
I was able to get this to work. No help needed now.
May 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mark | last post by:
All, Excuse the re-post but I have found something which works for the UserID but not for the Password (see previous post below). The problem is I don't understand how it works and therefore...
1
by: RockNRoll | last post by:
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...
2
by: Raed Sawalha | last post by:
Hi, This is probably pretty simple but... I am dynamically adding rows to a HtmlTable that contain Textbox controls. (There may be more than one server control/textbox in a given cell) How...
1
by: Atreju | last post by:
Ok I got form within a c sharp page. Situation: On the form I have a drop downliwst and a textbox, the dropdownlist is populated with products and the textbox has a default vale of the product...
1
by: swatidesai0407 | last post by:
im working on php i want the textbox value to pass in a href it goes as this <input type="text" name="use"> <a href="new.php?cat=textbox value dat is entered"> plz tell me wat to do
2
by: Nowezo | last post by:
Hi, Can you please help me, I want to write a dropdown box that have an option 'Other' but when the Other is selected my textbox need to be enable and take the textbox value as an output instead of...
1
by: viral123 | last post by:
Hi all I am using Crystal report and I am running my report successfully for my query but I want to make my query for one specific date. I want to get the date value from the textbox value. ...
4
by: billa856 | last post by:
Hi, I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx. example i have a table customer CID CNAME CSALARY 1 Billa ...
2
by: Archanak | last post by:
Hi, I have one common text box to get email id. I have 2 forms and both form action connects to different programs. I want to use this textbox value(i.e email id) only for both the forms. How...
10
by: pt36 | last post by:
Hi I have a page with a form and a textbox. before to submit the form I want to chek if the inserted value in the textbox is already present in a database. So I need to pass the textbox value...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.