Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a form that has various buttons on that when clicked display a modal popup. The popup displays correctly on the screen, but no data appears in any of the fields.

When I step through the code I can see that the data is being assigned to the relevant controls (textbox or label) but nothing appears. In my project I have several other forms that also have popups and these work as they should. I have even used the code from these forms to try and solve the issue but with no success.

This is the code where the user clicks the button to display the popup

<div class="tab-pane fade" id="tabDiary">
    <div class="col-md-12">
        <asp:UpdatePanel ID="updatePanelDiary" runat="server">
            <ContentTemplate>
                <%--<asp:Timer ID="timerDiary" runat="server" Interval="15000" OnTick="timerDiary_Tick"></asp:Timer>--%>
                <asp:Repeater ID="rptDiary" runat="server" OnItemDataBound="rptDiary_ItemDataBound">
                    <HeaderTemplate>
                        <div class="col-md-12 text-right">
                            <div class="form-group">
                                <asp:Button ID="btnDiary" runat="server" Text="New Diary Item" OnClick="btnDiary_Click" CssClass="btn btn-warning" Visible="true" />
                                <div class="clearfix"></div>
                            </div>
                        </div>
                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr class="tabHeaderRow">
                                    <td>Date</td>
                                    <td>Entered By</td>
                                    <td>Comments</td>
                                    <td>Action Date</td>
                                    <td></td>
                                </tr>
                            </thead>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td><%# DataBinder.Eval(Container.DataItem,"DateEntered") %></td>
                            <td><%# DataBinder.Eval(Container.DataItem,"AddedBy") %></td>
                            <td><%# DataBinder.Eval(Container.DataItem,"Comments") %></td>
                            <td><asp:Label ID="lblActionDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"ActionDate") %>'></asp:Label></td>
                            <td><asp:Button ID="btnEditDiaryEntry" runat="server" CssClass="btn btn-primary btn-sm" Text="Edit" CommandName="EditDiaryEntry"
                                 OnCommand="btnEditDiaryEntry_Command" CommandArgument='<%#Eval("DiaryID") %>' /></td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="clearfix"></div>
</div>


This is the code behind:

protected void btnEditDiaryEntry_Command(object sender, CommandEventArgs e)
{
    Int32 DiaryID = Convert.ToInt32(e.CommandArgument);
    SqlCommand cmd = new SqlCommand("sp_GetDiaryEntry", cnn);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@DiaryID", DiaryID);
    cnn.Open();

    SqlDataReader dr = cmd.ExecuteReader();
    while (dr.Read())
    {
        txtEditComment.Text = dr["Comments"].ToString();
        txtEditScheduleDiary.Text = dr["ActionDate"].ToString();
    }

    dr.Close();
    cnn.Close();
    ScriptManager.RegisterStartupScript(_parentControl, _parentControl.GetType(), "Modal", " DisplayEditDiaryModal()", true);
    Master.GetMenuData();
    txtEditScheduleDiary.Text = "hello david";

}


And this is the code to display the popup

<script type="text/javascript">
    function DisplayEditDiaryModal() {
        $('#<%=pnlDiaryEdit.ClientID%>').modal('show');
    }
</script>


What I have tried:

As I have already said this code works on other forms within the project. Any help would be much appreciated.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900