I would do it using Javascript!!!
Main Topics
Browse All TopicsHi All,
I have Gridview Control that populates data (4 colums) from database, I would like to highlight a particular text in this GridView such as, if I want apple highlighted in the gridview then the cells that carry apple in them, must be highlighted. How do I go about doing this?
Thank you,
Anusha
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Anushart, remember that regular expression is your best friend when it comes to string manipulation... :) This is pretty simple example and very efficient too. I don't know about the others, but I'd rather take care of string manipulation business on the client side as much as I can... :)
<html>
<head>
<script language="javascript">
function FindReplace(elemID,word)
{
var table=document.getElementB
var rows=table.rows;
var keyword=word.split(",").jo
var regex=new RegExp("\\b("+keyword+")\\
for (var i=0;i<rows.length;i++)
{
for (var j=0;j<rows[i].cells.length
{
var html=rows[i].cells[j].inne
rows[i].cells[j].innerHTML
var r="";
}
}
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>The quick brown fox jumped over the lazy dog</td>
<td>Another quick brown fox jumped over the lazy dog</td>
<td>Crazy quick brown fox jumped over the lazy dog</td>
<td>Little quick brown fox jumped over the lazy dog</td>
</tr>
<tr>
<td>The quick brown fox jumped over the lazy dog</td>
<td>Another quick brown fox jumped over the lazy dog</td>
<td>Crazy quick brown fox jumped over the lazy dog</td>
<td>Little quick brown fox jumped over the lazy dog</td>
</tr>
<tr>
<td>The quick brown fox jumped over the lazy dog</td>
<td>Another quick brown fox jumped over the lazy dog</td>
<td>Crazy quick brown fox jumped over the lazy dog</td>
<td>Little quick brown fox jumped over the lazy dog</td>
</tr>
<tr>
<td>The quick brown fox jumped over the lazy dog</td>
<td>Another quick brown fox jumped over the lazy dog</td>
<td>Crazy quick brown fox jumped over the lazy dog</td>
<td>Little quick brown fox jumped over the lazy dog</td>
</tr>
</table>
<script language="javascript">
FindReplace("myTable","qui
</script>
</body>
</html>
Hi,
If u want to highlight when adding to the grid then its simple while adding check the value of that cell the change the color. For example:
dataGridView1.Rows[0].Cell
if (dataGridView1.Rows[0].Cel
{
DataGridViewCellStyle dsstyle = new DataGridViewCellStyle();
ds.BackColor = Color.Yellow;
ds.ForeColor = Color.Black;
dataGridView1.Rows[0].Cell
}
udhayakumard:
Yes, that is what I wnat to do, but when I used the code you suggested, DatagridViewCellstyle was not being recognised, I checked the assembly references and the drawing reference has been included... So I tried to modify the code a little bit and here is what I have, but when I try to debug it..
if (GridView1.Rows[i].Cells[j
Please correct it if possible...
DataSet ds = new DataSet();
da.Fill(ds, "Tables");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
int nr = GridView1.Rows.Count;
int nc = GridView1.Columns.Count;
for (int i = 0; i < nr; i++)
{
for (int j = 0; j < nc; j++)
{
if (GridView1.Rows[i].Cells[j
{
GridView1.Rows[i].Cells[j]
}
}
}
}
Business Accounts
Answer for Membership
by: divinewind80Posted on 2007-06-20 at 12:35:28ID: 19327584
Are you wanting ONLY the word, or the cell that contains it?