Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm using this code for Json

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>

XML
<script type="text/javascript">
     jq(document).ready(function () {
         var jq = jQuery.noConflict();
         jq.ajax({
             type: "POST",
             contentType: "application/json; charset=utf-8",
             url: 'About.aspx/bindBannerRepeater',
             data: "{}",
             dataType: "json",
             success: function (data) {
                 for (var i = 0; i < data.d.length; i++) {
                     jq("#rep_banner").append("<li><img src=" + data.d[i].imgpath + "></li>");
                 }
             },
             error: function (result) {
                 alert("Error");
             }
         });
     });
</script>


and this is html binding code


XML
<ul class="slides">
               <asp:Repeater ID="rep_banner" runat="server">
               <ItemTemplate>
               <li><a href="aboutus.html"> <img src='<%#Eval("imgpath") %>' alt="image is not Displayed" width="200px" height="200px"  /></a></li>

               </ItemTemplate>
                           </asp:Repeater>
          </ul>




and this code in .cs file

[WebMethod]
public static bannertbl[] bindBannerRepeater()
{
DataTable dt = new DataTable();
List<bannertbl> details = new List<bannertbl>();

using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("select * from bannertbl ", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dtrow in dt.Rows)
{
bannertbl Emp = new bannertbl();
Emp.bannerid =Convert.ToInt32(dtrow["bannerid"].ToString());
Emp.imgpath = dtrow["imgpath"].ToString();
Emp.page = dtrow["page"].ToString();
details.Add(Emp);
}
}
}
return details.ToArray();
}




My images are not coming , while i'm binding data.I'm not getting what to do?
Posted
Updated 8-Jul-14 22:44pm
v2
Comments
jo.him1988 9-Jul-14 6:08am    
make sure about your image path
swatikapoor1a@gmail.com 9-Jul-14 7:11am    
yes my Image path is perfectly OK I've checked that already.

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