Click here to Skip to main content
15,882,114 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">
                <%--<asp:Timer ID="timerDiary" runat="server" Interval="15000" OnTick="timerDiary_Tick"></asp:Timer>--%>
                <asp:Repeater ID="rptDiary" runat="server" OnItemDataBound="rptDiary_ItemDataBound">
                        <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>
                        <table class="table table-striped table-bordered">
                                <tr class="tabHeaderRow">
                                    <td>Entered By</td>
                                    <td>Action Date</td>
                            <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>
    <div class="clearfix"></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);

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

    ScriptManager.RegisterStartupScript(_parentControl, _parentControl.GetType(), "Modal", " DisplayEditDiaryModal()", true);
    txtEditScheduleDiary.Text = "hello david";


And this is the code to display the popup

<script type="text/javascript">
    function DisplayEditDiaryModal() {

What I have tried:

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

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