模块化窗口不会显示在引导网格视图上

时间:2014-04-11 15:16:12

标签: c# asp.net sql twitter-bootstrap gridview

我正在尝试在按下视图详细信息按钮时,在模块化窗口中显示客户的详细信息。代码编译但是当我点击gridview中的视图详细信息按钮时,屏幕就会变暗,就好像它的加载......但没有任何加载。

我似乎可以弄清楚为什么它不会显示,任何帮助都会很棒,谢谢

编辑:我在主页文件中有jQuery和bootstrap调用

标记

  <%@ Page Title="" Language="C#" MasterPageFile="~/LetsRent.Master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="LetsRentAgentZoneB.Members.TestPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div style="width: 90%; margin-right: 5%; margin-left: 5%; text-align: center">
            <asp:ScriptManager runat="server" ID="ScriptManager1" />

            <h1>Grid View System</h1>

            <asp:UpdatePanel ID="upCrudGrid" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="GridViewUsers" runat="server" Width="940px" HorizontalAlign="Center"
                        OnRowCommand="GridView1_RowCommand" AutoGenerateColumns="false" AllowPaging="true"
                        DataKeyNames="LoweredEmail" CssClass="table table-hover table-striped">
                        <Columns>
                            <asp:ButtonField CommandName="detail" ControlStyle-CssClass="btn btn-info" ButtonType="Button" Text="Detail" HeaderText="Detailed View">
                                <ControlStyle CssClass="btn btn-info"></ControlStyle>
                            </asp:ButtonField>
                            <asp:ButtonField CommandName="editRecord" ControlStyle-CssClass="btn btn-info" ButtonType="Button" Text="Edit" HeaderText="Edit Record">
                                <ControlStyle CssClass="btn btn-info"></ControlStyle>
                            </asp:ButtonField>
                            <asp:ButtonField CommandName="deleteRecord" ControlStyle-CssClass="btn btn-info" ButtonType="Button" Text="Delete" HeaderText="Delete Record">
                                <ControlStyle CssClass="btn btn-info"></ControlStyle>
                            </asp:ButtonField>
                            <asp:BoundField DataField="LoweredEmail" />
                <asp:BoundField DataField="CreateDate" HeaderText="Created" HeaderStyle-HorizontalAlign="Left"/>
                <asp:BoundField DataField="LastLoginDate" HeaderText="Last Login" HeaderStyle-HorizontalAlign="Left" />
                <asp:BoundField DataField="LastLockoutDate" HeaderText="Last Lockout" HeaderStyle-HorizontalAlign="Left" />
                        </Columns>
                    </asp:GridView>
                    <asp:Button ID="btnAdd" runat="server" Text="Add New Record" CssClass="btn btn-info" OnClick="btnAdd_Click" />
                </ContentTemplate>
                <Triggers>
                </Triggers>
            </asp:UpdatePanel>



            <div id="detailModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">Details</h3>
                </div>
                <div class="modal-body">
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:DetailsView ID="DetailsView1" runat="server" CssClass="table table-bordered table-hover" BackColor="White" ForeColor="Black" FieldHeaderStyle-Wrap="false" FieldHeaderStyle-Font-Bold="true" FieldHeaderStyle-BackColor="LavenderBlush" FieldHeaderStyle-ForeColor="Black" BorderStyle="Groove" AutoGenerateRows="False">
                                <Fields>
                                    <asp:BoundField DataField="CreateDate" HeaderText="Created Date" />
                                    <asp:BoundField DataField="LoweredEmail" HeaderText="Email" />
                                    <asp:BoundField DataField="LastLoginDate" HeaderText="Last Login Date" />
                                    <asp:BoundField DataField="LastLockoutDate" HeaderText="Last Lockout Date" />
                                </Fields>
                            </asp:DetailsView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="GridViewUsers" EventName="RowCommand" />
                            <asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <div class="modal-footer">
                        <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                    </div>
                </div>
            </div>



            <div id="editModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="editModalLabel">Edit Record</h3>
                </div>
                <asp:UpdatePanel ID="upEdit" runat="server">
                    <ContentTemplate>
                        <div class="modal-body">
                            <asp:HiddenField ID="HfUpdateID" runat="server" />
                            <table class="table">
                                <tr>
                                    <td>Name : </td>
                                    <td>
                                        <asp:TextBox ID="txtNameUpdate" runat="server"></asp:TextBox></td>
                                    <td>
                                </tr>
                                <tr>
                                    <td>EmailID</td>
                                    <td>
                                        <asp:TextBox ID="txtEmailIDUpdate" runat="server"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>Address</td>
                                    <td>
                                        <asp:TextBox ID="txtAddressUpdate" runat="server"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>Contact No</td>
                                    <td>
                                        <asp:TextBox ID="txtContactUpdate" runat="server"></asp:TextBox></td>
                                </tr>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <asp:Label ID="lblResult" Visible="false" runat="server"></asp:Label>
                            <asp:Button ID="btnSave" runat="server" Text="Update" CssClass="btn btn-info" OnClick="btnSave_Click" />
                            <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="GridViewUsers" EventName="RowCommand" />
                        <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>



            <div id="addModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="addModalLabel">Add New Record</h3>
                </div>
                <asp:UpdatePanel ID="upAdd" runat="server">
                    <ContentTemplate>
                        <div class="modal-body">
                            <table class="table table-bordered table-hover">
                                <tr>
                                    <td>Name : </td>
                                    <td>
                                        <asp:TextBox ID="txtNameAdd" runat="server"></asp:TextBox></td
                                </tr>
                                <tr
                                    <td>EmailID :</td>
                                    <td>
                                        <asp:TextBox ID="txtEmailIDAdd" runat="server"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>Address:</td>
                                    <td>
                                        <asp:TextBox ID="txtAddressAdd" runat="server"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>Contact No:</td>
                                    <td>
                                        <asp:TextBox ID="txtContactAdd" runat="server"></asp:TextBox></td>
                                </tr>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <asp:Button ID="btnAddRecord" runat="server" Text="Add" CssClass="btn btn-info" OnClick="btnAddRecord_Click" />
                            <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Close</button>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnAddRecord" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>



            <div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="delModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="delModalLabel">Delete Record</h3>
                </div>
                <asp:UpdatePanel ID="upDel" runat="server">
                    <ContentTemplate>
                        <div class="modal-body">
                            Are you sure you want to delete the record?
                            <asp:HiddenField ID="HfDeleteID" runat="server" />
                        </div>
                        <div class="modal-footer">
                            <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="btn btn-info" OnClick="btnDelete_Click" />
                            <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">Cancel</button>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>



        </div>
</asp:Content>

代码隐藏

    namespace LetsRentAgentZone
{
    public partial class Users : System.Web.UI.Page
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LetsRent"].ConnectionString);

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                GetUsers();

        }

        protected void ExportCSVList(object sender, EventArgs e)
        {

            SqlCommand cmd = new SqlCommand("AgentGetUsers", conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("@OrderBy", SqlDbType.VarChar).Value = _orderByDropDown.SelectedValue;
            cmd.Parameters.Add("@SortBy", SqlDbType.VarChar).Value = _orderBySort.SelectedValue;

            conn.Open();

            DataTable dtTable = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dtTable);

            //DataTable dtTable = _usersGridView.DataSource as DataTable;

            Response.ContentType = "Application/x-msexcel";
            Response.AddHeader("content-disposition", "attachment;filename=Users-Export.csv");
            Response.Write(ExportToCSVFile(dtTable));
            Response.End();

        }

        private string ExportToCSVFile(DataTable dtTable)
        {
            StringBuilder sbldr = new StringBuilder();
            if (dtTable.Columns.Count != 0)
            {
                foreach (DataColumn col in dtTable.Columns)
                {
                    sbldr.Append(col.ColumnName + ',');
                }
                sbldr.Append("\r\n");
                foreach (DataRow row in dtTable.Rows)
                {
                    foreach (DataColumn column in dtTable.Columns)
                    {
                        sbldr.Append(row[column].ToString() + ',');
                    }
                    sbldr.Append("\r\n");
                }
            }
            return sbldr.ToString();
        }

        protected void GetUsers()
        {
            SqlCommand cmd = new SqlCommand("AgentGetUsers", conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("@OrderBy", SqlDbType.VarChar).Value = _orderByDropDown.SelectedValue;
            cmd.Parameters.Add("@SortBy", SqlDbType.VarChar).Value = _orderBySort.SelectedValue;

            conn.Open();

            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(ds);

            _usersGridView.DataSource = ds;
            _usersGridView.DataBind();

            conn.Close();
        }

        protected void SearchClick(object sender, EventArgs e)
        {
            GetUsers();
        }

        protected void UsersRowCommand(object sender, GridViewCommandEventArgs e)
        {
            MembershipUser user = Membership.GetUser(e.CommandArgument.ToString());

            switch (e.CommandName)
            {
                case "ChangeEnabled":

                    if (user.IsApproved)
                        user.IsApproved = false;
                    else
                        user.IsApproved = true;

                    Membership.UpdateUser(user);
                    GetUsers();

                    break;
                case "ChangeLocked":

                    if (user.IsLockedOut)
                        user.UnlockUser();

                    GetUsers();

                    break;
                case "ViewPerson":
                    GetPerson(e.CommandArgument.ToString());
                    break;
                default:
                    break;
            }
        }

        protected void CloseButtonClick(object sender, EventArgs e)
        {
            _userDetailsPanel.Visible = false;
        }

        protected void GetPerson(string email)
        {
            SqlCommand cmd = new SqlCommand("AgentGetUserByEmail", conn);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            SqlDataReader rdr;

            cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;

            conn.Open();
            rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                _nameLabel.Text = rdr["FirstName"].ToString() + " " + rdr["LastName"].ToString();
                _mobileLabel.Text = rdr["Mobile"].ToString();
                _referralCodeLabel.Text = rdr["ReferalCode"].ToString();
                _sourceLabel.Text = rdr["Source"].ToString();
                _roleLabel.Text = rdr["RoleName"].ToString();
            }

            rdr.Close();
            conn.Close();

            _userDetailsPanel.Visible = true;
        }

        protected void UsersRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label enabled = e.Row.FindControl("_enabledLabel") as Label;
                Label locked = e.Row.FindControl("_lockedOutLabel") as Label;

                ImageButton enabledBtn = e.Row.FindControl("_enabledButton") as ImageButton;
                ImageButton lockedBtn = e.Row.FindControl("_lockedButton") as ImageButton;

                if (enabled.Text == "True")
                    enabledBtn.ImageUrl = "/App_Themes/Default/Images/user_gray.png";
                else
                    enabledBtn.ImageUrl = "/App_Themes/Default/Images/user.png";

                if (locked.Text == "True")
                    lockedBtn.ImageUrl = "/App_Themes/Default/Images/lock_open.png";
                else
                    lockedBtn.Visible = false;
            }
        }

        protected void UsersPageChanging(object sender, GridViewPageEventArgs e)
        {
            _usersGridView.PageIndex = e.NewPageIndex;
            GetUsers();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

更改

<div id="detailModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

<div id="detailModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

删除&#34;隐藏&#34;你会看到窗口