0

I am working with ASP.net and C#

I have a GridView with Multiple rows. I have a text box and search button. My grid columns are Id and name. If I type a name in the text box and click search button. I have highlighted the names in the grid which I typed in the textbox and must scroll to the highlighted row.

How can I search and Highlight it but cannot scroll to the selected row?

Anthon
  • 51,019
  • 25
  • 150
  • 211
Amaladoss R
  • 69
  • 2
  • 9

1 Answers1

0

Try below function

function scrollToElement(selector, time, verticalOffset) {
time = typeof(time) != 'undefined' ? time : 500;
verticalOffset = typeof(verticalOffset) != 'undefined' ? verticalOffset : 0;
element = $(selector);
offset = element.offset();
offsetTop = offset.top + verticalOffset;
$('html, body').animate({
    scrollTop: offsetTop
}, time);
}

Call this function like scrollToElement('elementUniqueIdHere`, 750, -50);

Hope this helps you.

Sameer K
  • 757
  • 1
  • 6
  • 25