Hi felipe.oli,
I have created a sample which full fill your requirement
HTML
<div>
<div id="container" style="overflow: scroll; overflow-x: hidden">
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
<div>
<script type="text/javascript" src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript">
$(document).ready(function () {
var width = new Array();
var table = $("table[id*=GridView1]"); //Pass your gridview id here.
table.find("th").each(function (i) {
width[i] = $(this).width();
});
headerRow = table.find("tr:first");
headerRow.find("th").each(function (i) {
$(this).width(width[i]);
});
firstRow = table.find("tr:first").next();
firstRow.find("td").each(function (i) {
$(this).width(width[i]);
});
var header = table.clone();
header.empty();
header.append(headerRow);
header.append(firstRow);
header.css("width", width);
$("#container").before(header);
table.find("tr:first td").each(function (i) {
$(this).width(width[i]);
});
$("#container").height(300);
$("#container").width(table.width() + 20);
$("#container").append(table);
});
</script>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("SELECT CustomerId,ContactName,City,Country FROM Customers", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
ScreenShot