Aniruddh Kewat

Aniruddh Kewat

  • NA
  • 30
  • 20.6k

Page scroll not working when Linkbutton added to datalist ?

Jun 27 2015 4:13 AM
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
pageCount = parseInt(xml.find("PageCount").eq(0).find("PageCount").text());
var customers = xml.find("Customers");
var repeatColumns = parseInt("<%=dlproducts.RepeatColumns == 0 ? 1 : dlproducts.RepeatColumns %>");
var rowCount = Math.ceil(customers.length / repeatColumns);
var i = 0;
while (i < repeatColumns * rowCount) {
var row = $("[id*=dlproducts] tr").eq(0).clone(true);
for (var j = 0; j < repeatColumns; j++) {
var customer = $(customers[i]);
if (customer.length == 0) {
//alert('Bingo');
$("table:last", row).remove();
} else {
$(".name", row).eq(j).html(customer.find("Name").text());
$(".productId", row).eq(j).html(customer.find("ProductId").text());
$(".description", row).eq(j).html(customer.find("Description").text());
$(".imageUrl", row).eq(j).html(customer.find("ImageUrl").text());
$(".image", row).eq(j).attr("src", 'Images/' + customer.find("ImageUrl").text());
$(".price", row).eq(j).html(customer.find("Price").text());
$(".quantity", row).eq(j).html(customer.find("Quantity").text());
//$(".lbtnaddtocart", row).eq(j).text(customer.find("Name").text());
//this is where i m stuck,how to add contents to the linkbutton on scroll...... 
$(".lbtnaddtocart", row).eq(j).attr("CommandArgument", customer.find("ProductId").text()); 
}
i++;
}
$("[id*=dlproducts]").append(row);
}
//$("[id*=dlproducts] tr").eq(0).remove();
$("[id*=dlproducts]").show();
$("#loader").hide();
}
<asp:DataList ID="dlproducts" runat="server" RepeatLayout="Table" RepeatColumns="4"
RepeatDirection="Horizontal" CellPadding="0" CellSpacing="0" BackColor="AliceBlue"
Width="100%">
<ItemStyle Width="25%" />
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="width: 100%; height: 300px;
border: 2px solid Blue; background-color:; text-align: center">
<tr>
<td>
<b><u><span class="name">
<%# Eval("Name") %></span></u></b>
</td>
</tr>
<tr>
<td>
<b>Productid: </b><span class="productId" style="font-size: 20px; color: Yellow;
font-weight: 500;">
<%# Eval("Productid") %></span><br />
<b>Description </b><span class="description">
<%# Eval("Description") %></span><br />
<b>ImageUrl: </b><span class="imageUrl">
<%# Eval("ImageUrl")%></span><br />
<img class="image" alt='' src="Images/<%# Eval("ImageUrl")%>" width="160px" height="320px" /><br />
<b>Price: </b><span class="price">
<%# Eval("Price")%></span>
<img alt="" src="star-icon.png" />
<b>Quantity: </b><span class="quantity">
<%# Eval("Quantity")%></span><br />
<asp:LinkButton ID="lbtnAddtocart" runat="server" CommandArgument='<%#Eval("ProductId")%>'
BackColor="Green" Font-Bold="true" Text="Add To Cart" Width="150px" BorderColor="Black"
BorderStyle="Inset" BorderWidth="2px" ToolTip="Add To Cart"></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>