ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
var selectedRow = undefined;
function showpopup(obj) {
var modal = document.getElementById('myModal');
modal.style.display = "block";
selectedRow = obj.parentElement.parentElement;
var lbl = selectedRow.getElementsByClassName('clsRemarksGrid')[0]
var value = lbl.textContent;
document.getElementById('txtRemarks').value = value;
}
function closepopup() {
var modal = document.getElementById('myModal');
modal.style.display = "none";
}
function okpopup() {
debugger
var modal = document.getElementById('myModal');
modal.style.display = "none";
if(selectedRow ){
var lbl = selectedRow.getElementsByClassName('clsRemarksGrid')[0]
var value = document.getElementById('txtRemarks').value;
lbl.textContent = value;
}
}
</script>
<style>
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 400px;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s;
}
@-webkit-keyframes animatetop {
from {
top: -300px;
opacity: 0;
}
to {
top: 0;
opacity: 1;
}
}
@keyframes animatetop {
from {
top: -300px;
opacity: 0;
}
to {
top: 0;
opacity: 1;
}
}
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 5px;
background-color: #5cb85c;
color: white;
}
.modal-body {
padding: 5px;
height: 100px;
}
.modal-footer {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView runat="server" ID="gridView1" DataKeyNames="ENTRYNO"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="ENTRYNO" HeaderText="ENTRYNO" />
<asp:TemplateField HeaderText="A">
<ItemTemplate>
<asp:CheckBox ID="ChkApproved" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remarks">
<ItemTemplate>
<asp:Label ID="lblRemarksGrid" CssClass="clsRemarksGrid" runat="server" Text="" Width="200Px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="lnkRemark" Text="Add Remark" OnClientClick="showpopup(this); return false" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div id="myModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<span onclick="closepopup()" class="close">×</span>
<h2 style="margin: 3px;">Modal Header</h2>
</div>
<div class="modal-body">
Remarks:
<asp:TextBox ID="txtRemarks" runat="server"></asp:TextBox>
<br />
<button onclick="okpopup(); return false;">Ok</button>
</div>
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("ENTRYNO");
for (int i = 0; i < 5; i++)
dt.Rows.Add(i);
gridView1.DataSource = dt;
gridView1.DataBind();
}
}