473,473 Members | 4,257 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Find specific value in gridview

JustRun
127 New Member
Hi,

Well, I have a DataGridView binded to a TableAdapter and there is an extra empty column named "clmImg" to put an image or color in it.

I want to do the following :

search through the quantity column, if you find a value less than 15 then put a red color "or red image" in the empty column.

I don't know who to write the code. Any help??
Aug 16 '09 #1
1 5655
GaryTexmo
1,501 Recognized Expert Top Contributor
All right... so it's been a while since I've worked with a DataGridView so bear with me. I had to google how you got data out of a TableAdapter, but it seems like it's straightforward.

According to the MSDN article I found, TableAdapter.GetData gets you a DataTable for your DataGridView... and that's good enough for me.

So now you're looking for matches on the "quantity" column and want to do something to the clmImg column. No problem, first you need to search the table for a match. There's likely a few ways to do this...

1. Look up how to run an SQL query on a DataTable... I believe you can do this, try googling.
2. Use the DataTable.Select command
3. Manually search through the DataTable to find what you want...

I'll go through the 3rd option with you. I'm willing to bet it's not optimal, but when you play around with these objects like this, you get a better idea of how to use them, which is always a plus.

Basically, just go through the DataTable's rows and look for what you want, then assign the column you want. So basically...

Expand|Select|Wrap|Line Numbers
  1. DataTable dt = new DataTable();
  2. foreach (DataRow dr in dt.Rows)
  3. {
  4.   if (dr["quality"] <condition>)
  5.   {
  6.     dr["clmImg"] = <whatever>;
  7.   }
  8. }
Hopefully I got that right... and hopefully it helps. Good luck!
Aug 17 '09 #2

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

Similar topics

1
by: needin4mation | last post by:
protected void Page_Load(object sender, EventArgs e) { TextBox mpTextBox = (TextBox)(Master.FindControl("txtFreeSearch")); Response.Write("mp" + mpTextBox.Text); //only works the second time ...
1
by: Scott F K Hooper | last post by:
My ASP.NET 2.0 project has a GridView that I want to be able to edit and update records with. The GridView has been bound to an ObjectDataSource control that has the following Update method...
0
by: Dan | last post by:
Issue making textbox visible based on specific input from a radio button list in an EditItemTemplate I want to setup a gridview that when in edit mode and when the user selects "Other" from a...
1
by: umeshdchaudhari | last post by:
fist I filled value of drow down and GridView control. Now we find the databound of grid view control as per drow down value at time binding. ? How we find the value of control time of binding in...
2
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
Id there a why to find the height of a gridview after it has been created? Some lines will wrap making the gridview londer or shorter depending on the current page index. Reason: I'm attempting...
0
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I need to have a column in a gridview that cycles through a set of comma delimited values i.e. if you imagine a column where in one row the value might be "111,222" and in the next row it...
1
by: vinodkus | last post by:
dear sir/madam I have displayed data in gridview. after display of data i want some particular data from gridview by using index of that data in gridview. please tell me how it is possible like...
9
by: RobertTheProgrammer | last post by:
Hi folks, I've been struggling with this for a few hours and I'm hoping someone can help me out. On my GridView (with C# codebehind) I have a date entry field. To help users enter only valid...
0
by: Allan | last post by:
Hi, I am having trouble when I dynamically assign sqldatasources to a gridview. If I do not sort the gridviews, everything runs well even when I change the gridview's sqldatasource by changing the...
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
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,...
1
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...
0
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 ...
0
muto222
php
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.