How to highlight a gridrow based on value filter from the dataset. I want to show all data rows but highlight only the filtered rows
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manoj Kumar MandalPosted May 1, 2015, 1:38 AM
I prefer go for javascript in this case.
Try this code
for textbox Code
grv1 is the name of your gridviev.
For complete code download attached file.
Vincent Maverick DuranoPosted Apr 30, 2015, 8:54 AM
This should help you : Search records in GridView and highlight results in ASP.Net using C# and VB.Net
You can see the actual demo here: http://www.aspsnippets.com/Demos/922/
ashok kumarPosted Apr 30, 2015, 7:37 AM
I selected the Dropdown Nam, enter the txtbox ashok and click the button highlight the name in grid row using for dataset
Thanks in Advice
Manoj Kumar MandalPosted Apr 30, 2015, 7:02 AM
You can use OnRowDataBound event of grid to do so.
Here is a sample code for you
in aspx add
onrowdatabound="GridView1_RowDataBound"
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string i = e.Row.Cells[1].Text.ToString();
if(i.Equals("2"))
e.Row.BackColor = System.Drawing.Color.Red;
}
}
In this code i'm expecting that he value what you are matching exist on cell 1(cell count starts from 0 in grid) and checking if value is 2 change the color of row or else nothing.
---------------------------------------------------------------------------------------
If you find this answer helpful and solves your problem. Mark answered
Thank You