Contact Form

Name

Email *

Message *

Dynamic Slider Bootstrap in asp.net with C#

1 comment
<%@ Page Title="" Language="C#" MasterPageFile="~/EPC2s.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="EPC2.Admin.Index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<section id="slider"><!--slider-->
<div class="container">
<div class="row">
<div class="col-sm-12">
<div id="slider-carousel" class="carousel slide" data-ride="carousel">

                        <ol class="carousel-indicators">
                        <%=Indicators%>
</ol>

<div class="carousel-inner">
                        <%=str%>
</div>

<a href="#slider-carousel" class="left control-carousel hidden-xs" data-slide="prev">
<i class="fa fa-angle-left"></i>
</a>
<a href="#slider-carousel" class="right control-carousel hidden-xs" data-slide="next">
<i class="fa fa-angle-right"></i>
</a>
</div>

</div>
</div>
</div>
</section><!--/slider-->
<section>
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="left-sidebar">
<h2>Category</h2>
<div class="panel-group category-products" id="accordian"><!--category-productsr-->
<asp:ListView ID="lstcat" runat="server">
                            <ItemTemplate>
                            <div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a href="Products.aspx?BId=<%#Eval("BId") %>"><%#Eval("BName")%></a></h4>
</div>
</div></ItemTemplate>
                            </asp:ListView>
</div><!--/category-products-->

</div>
</div>

<div class="col-sm-9 padding-right">
<div class="features_items"><!--features_items-->
<h2 class="title text-center">Features Items</h2>
                    <asp:ListView ID="Lstprod" runat="server" DataKeyNames="PId"
   OnSelectedIndexChanging="ListView1_SelectedIndexChanging">
                    <ItemTemplate>
<div class="col-sm-4">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
                                         <a    href="Productdetail.aspx?Mod=<%#Eval("PId") %>" >
<img src='images/M/<%#Eval("PPic")%>' alt="" />
<h2>$<%#Eval("PPrice")%></h2>
<p><%#Eval("PName")%></p></a>
                <asp:LinkButton ID="lnkbtn" runat="server" class="btn btn-default add-to-cart" CommandName="Select"  ><i class="fa fa-shopping-cart"></i>Add to cart</asp:LinkButton>
</div>
</div>
</div>
</div>
                        </ItemTemplate>
</asp:ListView>
</div><!--features_items-->
</div>
</div>
</div>
</section>
</asp:Content>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE_EPC2;
using BL_EPC2;
using System.Text;
namespace EPC2.Admin
{
    public partial class Index : System.Web.UI.Page
    {
        //public StringBuilder str ,Indicators;
        //public StringBuilder strs, Indicatorss;
        public String str ,Indicators;
        //public String strs, Indicatorss;
        public int counter = 0;

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                BEProduct be = new BEProduct();
                Lstprod.DataSource = new BLProduct().show().OrderByDescending(id=>id.PId).Take(9);
                Lstprod.DataBind();
                lstcat.DataSource = new BLBrands().show();
                lstcat.DataBind();
               List<BESlider> list = new BLSlider().show();
               var listById = from n in list select n;
              
               foreach (BESlider item in listById)
               {
                   
                               if(counter == 0)

                    {
                        Indicators+=("<li data-target='#slider-carousel' data-slide-to='")+(counter)+("' class='active'></li>");

                        str += ("<div class='item active'><div class='col-sm-6'><h1><span>EPC2</span>-SOFTWARE</h1><h2>") + (item.SName.ToString()) + ("</h2><p>") + (item.SDescription.ToString()) + ("</p></div><div class='col-sm-6'><img src='images/Slider/") + (item.Spic2.ToString()) + (" ") + ("' class='girl img-responsive' alt='' /></div></div>");
                    }
                    else
                    {
                        Indicators += ("<li data-target='#slider-carousel' data-slide-to='") + (counter) + ("' ></li>");

                        str += ("<div class='item'><div class='col-sm-6'><h1><span>EPC2</span>-SOFTWARE</h1><h2>") + (item.SName.ToString()) + ("</h2><p>") + (item.SDescription.ToString()) + ("</p></div><div class='col-sm-6'><img src='images/Slider/") + (item.Spic2.ToString()) + (" ") + (" ' class='girl img-responsive' alt='' /></div></div>");

                    }
                    counter++;
                           }

            }


        }
        protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
        {
            Lstprod.SelectedIndex = e.NewSelectedIndex;

             string pid = Lstprod.SelectedDataKey.Value.ToString();

            //string pid = ListView1.DataKeys[e.NewSelectedIndex].Value.ToString(); 

             Session["Prodid"]=pid ;
             Response.Redirect("Addtocart.aspx");

          
        }
    }
}


1 comment :

  1. would you please send me project files, thanks
    m3is4m@gmail.com

    ReplyDelete