我想在listview中的模型弹出窗口中显示模型弹出窗口我希望在该模型弹出窗口中显示每一行数据

时间:2015-04-25 11:45:59

标签: javascript c# asp.net asp.net-mvc sql-server-2008

我试图在单击一行时获取模型弹出窗口,但我不知道如何处理和显示模型弹出窗口以及如何识别行ID以从数据库中获取该特定行的数据。 请尝试给我建议显示modelpopup。

下面的引导模型框中的lable文本我希望显示该行数据的详细信息

这是我的.aspx文件:

<!-- listview starting   -->
          <asp:ListView runat="server"  ID="listview1" ItemPlaceholderID="PlaceHolder4"  >
                                          <EmptyDataTemplate>
                                              <p class="control-label">OOPS! No Data Available</p>

                                           </EmptyDataTemplate>
                                           <LayoutTemplate>
                                              <table id="myTable2" class="table table-striped">  
                                             <thead>  
                                                <tr>  
                                                <th>SNo.</th>  
                                                <th>Date</th>  
                                                <th>Subject</th>  
                                                <th>Content</th>
                                                <th>Acknowledgement</th>
                                          </tr>  
                                            </thead>  
                                            <tbody>  
                                             <asp:PlaceHolder ID="PlaceHolder4" runat="server"></asp:PlaceHolder>
                                                </tbody>
                                                   </table>
                                           </LayoutTemplate>

                                           <ItemTemplate>
                                                    <tr>  
                                                <td>1</td> 
                                                <td><%# Eval("noti_date") %></td> 
                                                <td><%# Eval("noti_subject") %></td> 
                                                <td><asp:LinkButton ID="LinkButton1" data-toggle="modal" runat="server" data-target="#notifyModal" style="cursor:pointer;" Text='<%# Eval("noti_content") %>' ></asp:LinkButton></td>
                                                <td><span class="glyphicon glyphicon-check green "><%# Eval("ack") %></span></td>   

                                                </tr>  

                                          </ItemTemplate>          
                                 </asp:ListView>
<!-- listview end -->
<!-- model popup start -->
     <div class="modal fade" id="notifyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                              <div class="modal-dialog">
                                                <div class="modal-content">
                                                  <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title" id="myModalLabel">Notifications</h4>
                                                  </div>
                                                  <div class="modal-body">
                                                      <table class="table">
                                                          <tbody >
                                                              <tr>
                                                                  <td  style="border-top:none"></td><td  style="border-top:none"><b><asp:Label ID="lbl_date" CssClass="red" runat="server" Text="22/5/2015"></asp:Label></b></td>
                                                              </tr>
                                                              <tr>
                                                                   <td  style="border-top:none">Subject</td> <td  style="border-top:none"><asp:Label ID="lbl_sub" runat="server" Text="Update the Status"></asp:Label></td> 
                                                               </tr>
                                                              <tr>
                                                               <td  style="border-top:none">Sent By</td>  <td  style="border-top:none"><asp:Label ID="lbl_sentby" runat="server" Text="info@amcsquare.com"></asp:Label></td>
                                                              </tr> 
                                                              <tr>
                                                                  <td colspan="2"  style="border-top:none"><div class="panel panel-default" style="width:100%;"><div class="panel-body"><asp:Label ID="lbl_content" runat="server" Text="This is to inform you about Update your Status..."></asp:Label></div></div></td>
                                                              </tr>

                                                               <tr>
                                                                  <td  style="border-top:none"></td>  <td  style="border-top:none"> <div style="text-align:right;"><button type="button" class="btn btn-danger" data-dismiss="modal">Acknowledge</button></div></td>
                                                                </tr>
                                                            </tbody>
                                                          </table>
                                                  </div>

                                                </div>
                                              </div>
                                       </div>
 <!-- model popup end    -->
文件后面的

代码是:

protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsAuthenticated)
        {
            userid = HttpContext.Current.User.Identity.Name.ToString();
            if (!IsPostBack)
            {

                listview1.DataSource = UpdateProfile.getnotifications(userid);
                listview1.DataBind();
            }

        }
        else
        {
            Response.Redirect("/Default2.aspx");
        }
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }

1 个答案:

答案 0 :(得分:0)

对于模态弹出窗口,您可以使用以下代码

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<asp:ScriptManager ID="ScriptManager1" runat="server">

<!-- ModalPopupExtender -->
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1"   TargetControlID="Id of your Button On which you want to show popup"
CancelControlID="btnClose">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center"  Height="153px" Width="152px" >
<strong>This is an ASP.Net AJAX ModalPopupExtender Example</strong><br />
<asp:Button ID="btnClose" runat="server" Text="Close" />
</asp:Panel>
<!-- ModalPopupExtender -->

CSS Class

<style type="text/css">
.modalBackground
{
    background-color: Black;
    filter: alpha(opacity=90);
    opacity: 0.8;
}
.modalPopup
{
    border: 3px solid black;
        background-color: #FFFFFF;
        padding-top: 10px;
        padding-left: 10px;
        width:auto;
        height:auto;
    }