Hi fareed.fd7,
Refer the below sample and modify with your code.
HTML
<asp:Button runat="server" ID="btnView" Text="Search" class="btn btn-success btn-lg" OnClick="btnView_Click" />
<div>
<asp:GridView ID="GridView1" runat="server" CssClass="table table-striped table-hover"
DataKeyNames="student_Id" AutoGenerateColumns="false" GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Admission No">
<ItemTemplate>
<asp:Label ID="lblstudent_Id" runat="server" Text='<%# Eval("student_Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Month">
<ItemTemplate>
<asp:Label ID="lblMonth_Name" runat="server" Text='<%# Eval("Month_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# Eval("Amount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsPaid">
<ItemTemplate>
<asp:Label ID="lblIsPaid" runat="server" Text='<%# Eval("IsPaid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="date">
<ItemTemplate>
<asp:Label ID="lbldate" runat="server" Text='<%# Eval("date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pay">
<ItemTemplate>
<asp:LinkButton ID="lnkviewInvoice" runat="server" OnClick="lnkviewInvoice_Click">View</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title">Invoice View</h4>
</div>
<div class="modal-body">
<div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
<div class="form-group">
<asp:Label ID="lblstudent" runat="server" Text="Aadmission No: "></asp:Label>
<asp:Label ID="lblstudentid" runat="server" Text=""></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="Label1" runat="server" Text="Month"></asp:Label>
<asp:Label ID="lblmonth" runat="server" Text=""></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="lblAmount" runat="server" Text="Amount"></asp:Label>
<asp:TextBox ID="txtAmount" runat="server" TabIndex="3" MaxLength="75" CssClass="form-control"
placeholder="Enter Amount"></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btnSave" runat="server" Text="Pay" CssClass="btn btn-info" />
<button type="button" class="btn btn-info" data-dismiss="modal">
Close</button>
</div>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script type='text/javascript'>
function openModal() {
$('[id*=myModal]').modal('show');
}
</script>
</div>
</div>
C#
private void BindGrid()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("student_Id")
,new DataColumn("Month_Name")
,new DataColumn("Amount")
,new DataColumn("IsPaid")
,new DataColumn("date")});
dt.Rows.Add(1, "Jan", 5200, "Yes", DateTime.Now.AddDays(-263));
dt.Rows.Add(2, "Feb", 6500, "No", DateTime.Now.AddDays(-50));
dt.Rows.Add(3, "Mar", 7500, "", "");
dt.Rows.Add(4, "Apr", 6333, "No", DateTime.Now.AddDays(-63));
dt.Rows.Add(5, "Jun", 15000, "Yes", DateTime.Now.AddDays(-93));
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void btnView_Click(object sender, EventArgs e)
{
BindGrid();
}
protected void lnkviewInvoice_Click(object sender, EventArgs e)
{
int rowIndex = Convert.ToInt32(((sender as LinkButton).NamingContainer as GridViewRow).RowIndex);
GridViewRow row = GridView1.Rows[rowIndex];
lblstudentid.Text = (row.FindControl("lblstudent_Id") as Label).Text;
lblmonth.Text = (row.FindControl("lblMonth_Name") as Label).Text; ;
txtAmount.Text = (row.FindControl("lblAmount") as Label).Text;
ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openModal();", true);
}
Screenshot