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

How do I highlight a row in a datagrid?

I'm trying to highlight a specific row in a datagrid who's contition matches
..text = "Dawn"

i've been playing with the code below without much luck, is there a foreach
loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)

=== Code i've been playing with ===
for(int x=0;x<=dgQnARooms.Items.Count -1;x++)
{
if(dgQnARooms.Items[x].Cells[0].Text == "Dawn")
{
dgQnARooms.ItemStyle.BackColor = System.Drawing.Color.Cornsilk;
}
}
Nov 16 '05 #1
4 9644
This article might of help..
http://www.codeproject.com/csharp/cu...columnstyl.asp

HTH


"mike" <sp******@hotmail.com> wrote in message
news:hs*******************@fe1.news.blueyonder.co. uk...
I'm trying to highlight a specific row in a datagrid who's contition matches .text = "Dawn"

i've been playing with the code below without much luck, is there a foreach loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)

=== Code i've been playing with ===
for(int x=0;x<=dgQnARooms.Items.Count -1;x++)
{
if(dgQnARooms.Items[x].Cells[0].Text == "Dawn")
{
dgQnARooms.ItemStyle.BackColor = System.Drawing.Color.Cornsilk;
}
}

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.714 / Virus Database: 470 - Release Date: 2/07/2004
Nov 16 '05 #2
Does this work the same way for ASP.net datagrid?

Thanks
Mike
"Kayess" <no**********@kayess.com.au> wrote in message
news:AY****************@nnrp1.ozemail.com.au...
This article might of help..
http://www.codeproject.com/csharp/cu...columnstyl.asp

HTH


"mike" <sp******@hotmail.com> wrote in message
news:hs*******************@fe1.news.blueyonder.co. uk...
I'm trying to highlight a specific row in a datagrid who's contition

matches
.text = "Dawn"

i've been playing with the code below without much luck, is there a

foreach
loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)

=== Code i've been playing with ===
for(int x=0;x<=dgQnARooms.Items.Count -1;x++)
{
if(dgQnARooms.Items[x].Cells[0].Text == "Dawn")
{
dgQnARooms.ItemStyle.BackColor = System.Drawing.Color.Cornsilk;
}
}

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.714 / Virus Database: 470 - Release Date: 2/07/2004

Nov 16 '05 #3
No it is different, there is another article you may
find useful:
http://www.csharphelp.com/archives3/archive543.html
about 3/4 down the page there is a section on highlighting.

HTH
Steve
"mike" <sp******@hotmail.com> wrote in message
news:S8*******************@fe1.news.blueyonder.co. uk...
Does this work the same way for ASP.net datagrid?

Thanks
Mike
"Kayess" <no**********@kayess.com.au> wrote in message
news:AY****************@nnrp1.ozemail.com.au...
This article might of help..
http://www.codeproject.com/csharp/cu...columnstyl.asp

HTH


"mike" <sp******@hotmail.com> wrote in message
news:hs*******************@fe1.news.blueyonder.co. uk...
I'm trying to highlight a specific row in a datagrid who's contition

matches
.text = "Dawn"

i've been playing with the code below without much luck, is there a

foreach
loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)

=== Code i've been playing with ===
for(int x=0;x<=dgQnARooms.Items.Count -1;x++)
{
if(dgQnARooms.Items[x].Cells[0].Text == "Dawn")
{
dgQnARooms.ItemStyle.BackColor = System.Drawing.Color.Cornsilk;
}
}

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.714 / Virus Database: 470 - Release Date: 2/07/2004


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.714 / Virus Database: 470 - Release Date: 2/07/2004
Nov 16 '05 #4
Hi,

You can do that using the ItemDataBound event of the grid, and change the
CSS of that row.

You can also use Page.PreRender event and iterate in the rows and also set
the correct CSS for that row.

I have some code if you need it.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"mike" <sp******@hotmail.com> wrote in message
news:hs*******************@fe1.news.blueyonder.co. uk...
I'm trying to highlight a specific row in a datagrid who's contition matches .text = "Dawn"

i've been playing with the code below without much luck, is there a foreach loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)

=== Code i've been playing with ===
for(int x=0;x<=dgQnARooms.Items.Count -1;x++)
{
if(dgQnARooms.Items[x].Cells[0].Text == "Dawn")
{
dgQnARooms.ItemStyle.BackColor = System.Drawing.Color.Cornsilk;
}
}

Nov 16 '05 #5

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

Similar topics

1
by: Gerg | last post by:
The datagrid has a tablestyle applied to it, and there are DataGridTextBoxColumn and each DataGridTextBoxColumn has an array of DataGridTextBox objects. Private Sub highlight(ByVal str As...
1
by: Michael Ramey | last post by:
I'm using the following code to highlight the current row: private void Datagrid1_CurrentCellChanged(object sender, System.EventArgs e) { DataGrid1.Select(DataGrid1.CurrentRowIndex); } The...
6
by: VM | last post by:
I have a 35000 line datagrid and updating one field in all 35000 rows takes an eternity. How come? Since I don't have the datasource available (it may be a table or view), in my example I do it...
0
by: back2grid | last post by:
I'm basically looking for highlighting a datagrid row on selection a radio button control. the problem i'm having is that the event sender(radio btn) i'm getting is functioning as a checkbox. my...
2
by: Mike | last post by:
How can i highlight a row in my datagrid when the user clicks it? I can do this in VB.NET but my app is in C#.
6
by: LU | last post by:
A)I build a datagrid based on a calendar date selection. B)When user clicks a button column on the datagrid I want to highlight this row. I use the code below to highlight the row. ***** CODE...
2
by: Bunnist-Priest | last post by:
Hello Everyone, My first predicament is that I want to make a colomn of my vb.net DataGrid a ProgressBar colomn. (full of Pr.Bars). Is it that difficult? Is there a code example? using - Dim...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
0
by: rn5a | last post by:
How to highlight a row in a DataGrid that has just been edited? EditItemStyle-BackColor will highlight a row when the DataGrid (& a row) is in the editable mode. I want to highlight the row...
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:
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: 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
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: 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
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.