[英]Carousel not working inside modal of bootstrap in asp.net
This is my carousal. 这是我的狂欢。
<div class="modal-body mbody">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<asp:Repeater ID="repid" runat="server">
<ItemTemplate>
<img alt="" style='height: 275px; width: 275px' src='<%# Eval("imgPath") %>' />
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</ContentTemplate>
</div>
And this is my .cs part.I have included this event in the pageload.I mean the repeater is binded with database. 这是我的.cs部分。我已经在页面加载中包含了此事件。我的意思是转发器已与数据库绑定。
public void bindslide()
{
//string str = Session["userid"].ToString();
string str = "22";
sq.connection();
SqlCommand cmd = new SqlCommand("select * from mygallary where regId_img='" + str + "' ", sq.con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
repid.DataSource = ds;
repid.DataBind();
sq.con.Dispose();
sq.con.Close();
}
What happens is that the image are loaded side by side instead of sliding.Where did i go wrong? 发生的情况是图像并排加载而不是滑动。我在哪里出错?
Edit This is what i am getting. 编辑这就是我得到的。
According to this link: http://webdesign.tutsplus.com/articles/twitter-bootstrap-101-the-carousel--webdesign-7442 the contents of each carousel item should be wrapped with a div
of class item
. 根据此链接: http : //webdesign.tutsplus.com/articles/twitter-bootstrap-101-the-carousel--webdesign-7442每个轮播项目的内容都应以div
类的item
包装。 I'd start by amending your code to read: 首先,将您的代码修改为:
<div class="carousel-inner">
<asp:Repeater ID="repid" runat="server">
<ItemTemplate>
<div class='item'>
<img alt="" style='height: 275px; width: 275px' src='<%# Eval("imgPath") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
Well You have item
and item active
class missing in your code.You can modify your repeater and add <div class='item'>
and <div class='item active'>
inside your ItemTemplate
respectively. 好了,您的代码中缺少item
和item active
类。您可以修改转发器,并在ItemTemplate
分别添加<div class='item'>
和<div class='item active'>
。
<asp:Repeater ID="repid" runat="server">
<ItemTemplate>
<div class="item" >
<div class="item active">
<asp:Image ID="imgId" runat="server" ImageUrl='<%#Eval("imgPath") %>' />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
For more see https://unschoolingcode.wordpress.com/2014/08/08/using-carousal-to-display-image-slide-from-database-in-asp-net/ 有关更多信息,请参见https://unschoolingcode.wordpress.com/2014/08/08/using-carousal-to-display-image-slide-from-database-in-asp-net/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.