TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ashok kumar
NA
33
17k
gridview select row change color
May 15 2015 9:04 AM
We have 100 records in gridview and we want to select 90th record. But user is not interested to scroll through mouse and see that record.
I have one textbox and button if i enter the column value the particular row will be scroll and highlighted this is my Source code
protected void Button1_Click(object sender, EventArgs e)
{
String searchTerm = TextBox3.Text;
//if the column index is 1 the we search by code and 2 if we search by name
int columnIndex = 1;
bool found = false;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
//change background color to yellow for the rows that contain the searched value
if (GridView1.Rows[i].Cells[columnIndex].Text.ToString().StartsWith(searchTerm))
{
if (searchTerm != "")
{
GridView1.Rows[i].BackColor = Color.SkyBlue;
}
else
{
GridView1.Visible = true;
GridView1.Rows[0].BackColor = Color.SkyBlue;
}
}
Thank you,
Reply
Answers (
3
)
mvc5
MVC4