Hi G.Madri,
I have cross checked your code and its working fine for me and i have put modal show script at the end
Refer below
HTML
<div>
<asp:GridView ID="GridView1" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
AutoGenerateSelectButton="true">
</asp:GridView>
</div>
<div class="modal" id="DispatchDetails" data-backdrop="static" data-keyboard="false"
data-toggle="modal">
<div class="modal-dialog">
<div class="modal-content panel-default">
<!-- Modal Header -->
<div class="modal-header panel-heading" style="background-color: #d9f2df">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span> <span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myGrnLabelHistory">
<asp:Label runat="server" CssClass="control-label" ID="lblRefNo" Font-Bold="True"
Font-Size="Medium">
<asp:Label ID="lblGrnNo" runat="server" Text="" ForeColor="#666666"></asp:Label></asp:Label>
</h4>
</div>
<div class="modal-body" style="padding-left: 15px; font-size: small">
<div class="form-group">
<asp:Label ID="Label1" runat="server" CssClass="col-md-3" Font-Bold="True" Width="100px">Txn Date:</asp:Label>
<asp:Label ID="lblTxnDate" runat="server" Width="100px"></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="Label2" runat="server" CssClass="col-md-3" Font-Bold="True" Width="100px">Dealer:</asp:Label>
<asp:Label ID="lblDealer" runat="server"></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="Label3" runat="server" CssClass="col-md-3" Font-Bold="True" Width="100px">Address:</asp:Label>
<asp:Label ID="lblAddress" runat="server"></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="Label4" runat="server" CssClass="col-md-3" Font-Bold="True" Width="100px">Memo:</asp:Label>
<asp:Label ID="lblMemo" runat="server"></asp:Label>
</div>
<asp:GridView ID="GridView2" ClientIDMode="Static" runat="server" CssClass="table table-striped table-bordered table-hover"
AutoGenerateColumns="False" EmptyDataText="There are no data records to display."
Height="16px" ShowFooter="True">
<Columns>
<asp:BoundField DataField="ItemCode" HeaderText="Item">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="Qty" HeaderText="Qty">
<HeaderStyle HorizontalAlign="Right" CssClass="gridViewHeader" />
<ItemStyle Width="50px" HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
<FooterStyle Font-Bold="True" />
<PagerStyle CssClass="pagination-ys" BackColor="White" />
</asp:GridView>
</div>
<div class="modal-footer" style="height: 60px">
<button type="button" class="btn btn-default btn-sm" data-dismiss="modal" style="width: 70px">
Close</button>
</div>
</div>
<div>
</div>
</div>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("RefNo"), new DataColumn("Txn Date"), new DataColumn("Dealer"), new DataColumn("Address"), new DataColumn("Memo") });
dt.Rows.Add("DDO1", "18-01-2017", "Seegiri Tele Shop", "Main Street, Sooriyawawa", "sdsd");
dt.Rows.Add("DDO2", "18-01-2017", "Seegiri Tele Shop", "Main Street, Sooriyawawa", "aaa");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
// string txnId = GridView1.DataKeys[GridView1.SelectedRow.RowIndex].Values[0].ToString().Trim();
lblRefNo.Text = GridView1.SelectedRow.Cells[1].Text;
lblTxnDate.Text = GridView1.SelectedRow.Cells[2].Text;
lblDealer.Text = GridView1.SelectedRow.Cells[3].Text;
lblAddress.Text = GridView1.SelectedRow.Cells[4].Text;
lblMemo.Text = GridView1.SelectedRow.Cells[5].Text;
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#DispatchDetails').modal();", true);
}
catch (Exception ex)
{
//shared.WriteLog(ex.Message, "FindDispatchNote", "gvDDO_SelectedIndexChanged");
}
}
ScreenShot
