问题
I have a Products
page which displays a list of products. When i click Details
button, i want to show product details in a bootstrap modal popup.
I want to get one of the product detail but this code gets all products details.
how can i fix this query:
.aspx code:
<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:
DataTable dtProductsDetails = system.GetDataTable("Select ProductDetails,TechDetails,Standards, ApplicationArea from TBLPRODUCTS where ProductID = ProductID");
if (dtProductsDetails.Rows.Count > 0)
{
rpProductDetails.DataSource = dtProductsDetails;
rpProductDetails.DataBind();
}
回答1:
<script type="text/javascript">
function openModal() {
$('#myModal').modal('show');
}
</script>
In your c# code add an event for linkbutton like
protected void lbEdit_Click(object sender, EventArgs e) {
ScriptManager.RegisterStartupScript(this,this.GetType(),"Pop","openModal();", true);
}
回答2:
You have to use jQuery for this:
$("a").click(function(){
$("#myModal2").modal("show");
});
来源:https://stackoverflow.com/questions/35312965/using-bootstrap-modalpopup-in-asp-net