On the gridview selected index chanaged event it shows empty modal. Assume that I have clicked DDO1 at the first time. It shows empty modal. When at the second time I clicked on the DDO2, it shows the data of DDO1.At third time when I clicked on DDO1 again, it shows the data of DDO2. It's like showing the previously fetched data. But when debugging,it is fetching correct data. Is there any missing parts of this design?
<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 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 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 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 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>
Code behind
protected void gvDDO_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#DispatchDetails').modal();", true);
string txnId = gvDDO.DataKeys[gvDDO.SelectedRow.RowIndex].Values[0].ToString().Trim();
lblRefNo.Text = gvDDO.SelectedRow.Cells[1].Text;
lblTxnDate.Text = gvDDO.SelectedRow.Cells[2].Text;
lblDealer.Text = gvDDO.SelectedRow.Cells[3].Text;
lblAddress.Text = gvDDO.SelectedRow.Cells[4].Text;
lblMemo.Text = gvDDO.SelectedRow.Cells[5].Text;
DataTable dt = findDispatchNoteService.getDispatchNoteDetails(txnId);
GridView2.DataSource = dt;
GridView2.DataBind();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#DispatchDetails').modal();", true);
}
catch (Exception ex)
{
shared.WriteLog(ex.Message, "FindDispatchNote", "gvDDO_SelectedIndexChanged");
}
}