Code is working On Master Page. I haved checked same code on Master Page It working properly If we added Content On Master page and The Code in Master Page.cs file.
MasterPage
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#dialog").dialog({
autoOpen: false,
modal: true,
title: "Transfer Row Details",
width: 450,
height: 450
});
$('#btnDisplay').click(function () {
$("#dialog").dialog('open');
return false;
});
$('[id*=chk]').click(function () {
if ($(this)[0].checked) {
var headerRow = $('#gvAll tbody tr:first').clone(true);
var row = ''; //$(this).closest('tr').clone(true);
var tds = '';
$($(this).closest('tr').find('td')).each(function (i, item) {
if (i > 0) {
tds += item.outerHTML;
}
});
row += "<tr>" + tds + "</tr>";
$('#gvSelected').append(row);
}
});
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Button ID="btnDisplay" Text="Display" runat="server" />
<div>
<div id="dialog" style="display: none">
<asp:GridView ID="gvAll" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="name" />
<asp:BoundField DataField="price" HeaderText="price" />
<asp:BoundField DataField="tax" HeaderText="tax" />
</Columns>
</asp:GridView>
<br />
<asp:GridView ID="gvSelected" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
</asp:GridView>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
MasyetPage.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("name",typeof(string))
,new DataColumn("price",typeof(string))
,new DataColumn("tax",typeof(string))
});
dt.Rows.Add("Name 1", "44", "5");
dt.Rows.Add("Name 2", "50", "4");
dt.Rows.Add("Name 3", "60", "3");
dt.Rows.Add("Name 4", "70", "2");
dt.Rows.Add("Name 5", "80", "1");
dt.Rows.Add("Name 6", "90", "7");
gvAll.DataSource = dt;
gvAll.DataBind();
dt.Clear();
dt.Rows.Add();
gvSelected.DataSource = dt;
gvSelected.DataBind();
gvSelected.Rows[0].Visible = false;
}
}
Child Page
HTML
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
Check On Child Page
</asp:Content>
Screenshot