I've been using this code on javascript to perform filtering on key press.
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("Name", sender.get_value(), "Contains");
But can anyone tell me how to do I archive this on code behind via a button?
You have to set the filterexpression of the grid manually. Check out the following online demo which illustrates how to implement filtering on a button click: Web Mail Grid