Hi manishvad,
I have created sample with masterpage by refering the below link.
MasterPage.master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
CS.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="CS.aspx.cs" Inherits="CS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server" AutoGenerateSelectButton="true"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="OrderID">
<ItemTemplate>
<asp:Label ID="lblOrderID" Text='<%#Eval("OrderID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CustomerID">
<ItemTemplate>
<asp:Label ID="lblCustomerID" Text='<%#Eval("CustomerID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/ScrollableGridPlugin_ASP.NetAJAX_3.0.js" type="text/javascript"></script>
<script type="text/javascript">
var position = 0;
$(document).ready(function () {
$('#<%=GridView1.ClientID %>').Scrollable({ ScrollHeight: 300, IsInUpdatePanel: true });
});
</script>
</asp:Content>
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string constr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("SELECT OrderID,CustomerID FROM Orders", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = GridView1.SelectedIndex;
Label lblOrderID = GridView1.Rows[selectedIndex].FindControl("lblOrderID") as Label;
lblOrderID.Text = "Changed OrderID";
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim constr As String = ConfigurationManager.ConnectionStrings("ConString").ConnectionString
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand("SELECT OrderID,CustomerID FROM Orders", con)
Dim sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim selectedIndex As Integer = GridView1.SelectedIndex
Dim lblOrderID As Label = TryCast(GridView1.Rows(selectedIndex).FindControl("lblOrderID"), Label)
lblOrderID.Text = "Changed OrderID"
End Sub
Screenshot