Bootstrap模式在显示时丢失数据 [英] Bootstrap modal losing data when displayed

查看:85
本文介绍了Bootstrap模式在显示时丢失数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,当单击显示模式弹出窗口时,其上有各种按钮。弹出窗口在屏幕上正确显示,但任何字段中都不显示任何数据。



当我单步执行代码时,我可以看到数据被分配给相关控件(文本框或标签)但没有出现。在我的项目中,我还有其他几种形式也有弹出窗口,这些形式可以正常工作。我甚至使用这些表单中的代码来尝试解决问题但没有成功。



这是用户单击按钮以显示弹出窗口的代码



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.

推荐答案

('#<%= pnlDiaryEdit.ClientID%>')。modal('show');
}
< / script>
('#<%=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.


这篇关于Bootstrap模式在显示时丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆