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;
}
}
Loading
Manoj Kumar Mandal198 reputationPosted May 19, 2015, 9:29 PM EDT
ashok kumar30 reputationPosted May 20, 2015, 10:12 PM EDT
var gvChecking = document.getElementById("<%= GridView1.ClientID %>");
var FindText = document.getElementById("<%= TextBox3.ClientID %>").value;
var oRows = gvChecking.rows;
var rawDataRows = new Array();
var cell;
var hdnCounterNext = document.getElementById("<%= hdnCounterNext.ClientID %>").value;
for (var i = hdnCounterNext; i < oRows.length; i++) {
var cell = gvChecking.rows[i].cells[0];
if (cell.innerHTML.indexOf(FindText) !== -1) {
// alert("found at " + i);
cell.scrollIntoView();
cell.style.backgroundColor = "orange"
// document.getElementById("<%= hdnCounterNext.ClientID %>").value = 0;
}
else {
cell.style.backgroundColor = "white";
}
}
return false;
}
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts