Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I´m trying to show some images dynamically in a web form but no luck yet. I´m kind of a newbie. This is my code, i appreciate any help.

ASP.NET
<div class="container">
  <div class="mainbanner">
  <div id="main-banner" class="owl-carousel home-slider" data-ride="Carousel">
      <%--Indicators--%>
      <ol class="carousel-indicators">
          <li data-target="#main-banner" data-slide-to="0" class="active"></li>
          <li data-target="#main-banner" data-slide-to="1"></li>
          <li data-target="#main-banner" data-slide-to="2"></li>
          <li data-target="#main-banner" data-slide-to="3"></li>
      </ol>
      <div class="owl-carousel carousel-inner" role="listbox">
          <asp:Repeater ID="rptrImages" runat="server">
              <ItemTemplate>
                  <div class="item active">
                      <img src="../Images/<%#DataBinder.Eval(Container.DataItem,"codigo") %>.jpg" />                      
                  </div>
              </ItemTemplate>
          </asp:Repeater>
      </div>
      <a class="left carousel-control" href="#main-banner" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
      </a>
      <a class="left carousel-control" href="#main-banner" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
      </a>
   </div>
</div>
</div>

This is the code for my data binder

C#
private void BindImageRepeater()
        {
            string cs = ConfigurationManager.ConnectionStrings["Conn_Speeder"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(cs))
            {
                conn.Open();
                SqlCommand command = new SqlCommand("Select [codigo],[descripcion] from dbo.Products", conn);                
                using (SqlDataAdapter da = new SqlDataAdapter(command))
                {
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    rptrImages.DataSource = dt;
                    rptrImages.DataBind();
                }   
            }
        }


What I have tried:

Connection works fine, the DataTable is filling correclty, but there is no show in the main page.
Posted
Updated 16-Oct-20 12:47pm
v2
Comments
Sandeep Mewara 17-Oct-20 7:40am    
Can you plrovide sample of data retrieved from database? What you get when you do: "Select [codigo],[descripcion] from dbo.Products"
CarlosRusso 19-Oct-20 11:51am    
codigo, descripcion
ABRSHI0033 Abrazadera con tornillo para Maza SHIMANO CB-E110 contra pedal CB-E110 (Complemento) 3 pza
ADASHI0008 Adaptador para Torre SHIMANO SM-ST74 Soldable Palanca Tipo Dual Aluminio
CADSHI0430 Cadena SHIMANO CN-HG53 116 Eslabones 9P. Negro/Gris*
CADSHI0565 Cadena SHIMANO CN-HG95 116 Eslabones 10P. Gris
CADSHI0663 Cadena SHIMANO CN-HG54 116 Eslabones 10P. Gris
CADSHI0669 Cadena SHIMANO CN-HG701 116 Eslabones 11P. Plata
CADSHI0671 Cadena SHIMANO  CN-HG901 114 Eslabones 11P. Plata
CFFSHI0355 Cable con Forro SHIMANO 1400X1600mm Para Palanca de Freno Trasero MTB
CFFSHI0361 Cable con Forro SHIMANO 800X900mm para Palanca de Freno Delantero Ruta
CLPSHI0561 Caliper para Freno de Disco SHIMANO BR-M375 Mecanico Delantero sin Rotor Altus
CLPSHI0562 Caliper para Freno de Disco SHIMANO BR-M375 Mecanico Trasero sin Rotor Altus
CLPSHI0564 Caliper para Freno de Disco SHIMANO BR-TX805 Mecanico Trasero sin Rotor Tourney
CLPSHI0566 Caliper para Freno de Disco SHIMANO BR-R317 Mecanico Delantero Ruta Negro sin Rotor Sora
CLPSHI0567 Caliper para Freno de Disco SHIMANO BR-R317 Mecanico trasera Ruta Negro sin Rotor Sora
F-ES Sitecore 17-Oct-20 11:20am    
Use the network section of the browser tools (f12) to see if the requests for the images are working or not. If they are responding with a 404 then you're not requesting from the right path.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900