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,
Loading
Nanhe SiddiquePosted May 16, 2015, 12:39 AM
on gridview selected index changed event write following code
Dipankar BiswasPosted May 15, 2015, 9:39 AM
Check this example..http://www.c-sharpcorner.com/UploadFile/rohatash/how-to-get-the-selected-row-in-gridview-using-Asp-Net/
Vincent Maverick DuranoPosted May 15, 2015, 9:34 AM
DEMO: http://aspsnippets.com/demos/685/