简体   繁体   English

在ASP.NET中使用引导模态弹出窗口

[英]Using bootstrap modalpopup in ASP.NET

I have a Products page which displays a list of products. 我有一个“ Products页面,其中显示了产品列表。 When i click Details button, i want to show product details in a bootstrap modal popup. 当我单击“ Details按钮时,我想在引导模式弹出窗口中显示产品详细信息。

在此处输入图片说明

I want to get one of the product detail but this code gets all products details. 我想获取产品详细信息之一,但是此代码获取所有产品详细信息。

在此处输入图片说明

how can i fix this query: 我该如何解决此查询:

.aspx code: .aspx代码:

<asp:Repeater ID="rpProducts" runat="server">
<ItemTemplate>
     <td> <div class="btn-ud" ><a href="<%#Eval("ProductID") %>" data-toggle="modal" data-target="#myModal2" class="btn btn-custom-3 btn-sm"/ >Details</a> </div> </td> 
</ItemTemplate>
</asp:Repeater>

modal popup code: 模态弹出代码:

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
<asp:Repeater ID="rpProductDetails" runat="server">
<ItemTemplate>
<tbody>
<td height="100px"> <%#Eval("ProductDetails")%> </td>
<td height="100px">  <%#Eval("ProductDetails")%> </td>
</tbody>
</ItemTemplate>
</asp:Repeater>      
</div>    

c# code: C#代码:

DataTable dtProductsDetails = system.GetDataTable("Select ProductDetails,TechDetails,Standards, ApplicationArea from TBLPRODUCTS where ProductID = ProductID");
          if (dtProductsDetails.Rows.Count > 0)
          {
              rpProductDetails.DataSource = dtProductsDetails;
              rpProductDetails.DataBind();
          }

You have to use jQuery for this: 您必须为此使用jQuery:

$("a").click(function(){
    $("#myModal2").modal("show");
});
    <script type="text/javascript">
      function openModal() {
      $('#myModal').modal('show');
    }
    </script>

In your c# code add an event for linkbutton like 在您的C#代码中为linkbutton添加一个事件,例如

    protected void lbEdit_Click(object sender, EventArgs e) {   
     ScriptManager.RegisterStartupScript(this,this.GetType(),"Pop","openModal();", true);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM