How to bind Datalist on dropdown change where its binded in pageload fully?
I want to show total images on load so its getting succesfully but now want to show on condition base like if color is 'red' then should show only red color images in datalist..I tried and getting perticular data but showing all images.. so how to show only those images which getting data in Jquery?
/*asp.net datalist control*/
Code
asp:DataList ID="dlCustomers" runat="server" RepeatLayout="Table" RepeatColumns="6">Code
ItemTemplate> table class="item">Code
Bash
img id="Image1" alt='' src='' class="image" height="60px" width="100px" /> td> tr>C#
asp:Label class="postal" Height="20px" Width="100px" runat="server" Text='' Font-Size="10px">asp:Label>Code
td> tr> table> ItemTemplate> asp:DataList>/*/on page load showing these below data images/*/
Code
$(function () {Code
$("[id*=dlCustomers]").hide();Code
$.ajax({Code
type: "POST",Code
url: "Default2.aspx/GetCustomers",Code
data: '{}',Code
contentType: "application/json; charset=utf-8",Code
dataType: "json",Code
success: OnSuccess,Code
failure: function (response) {Code
alert(response.d); },Code
error: function (response) {Code
alert(response.d); } }); });Code
function OnSuccess(response) {Code
var xmlDoc = $.parseXML(response.d);Code
var xml = $(xmlDoc);Code
var customers = xml.find("Table");Code
var repeatColumns = parseInt("");Code
var rowCount = Math.ceil(customers.length / repeatColumns);Code
var i = 0; while (i repeatColumns * rowCount) {Code
var row = $("[id*=dlCustomers] tr").eq(0).clone(true);Code
for (var j = 0; j repeatColumns; j++) {Code
var customer = $(customers[i]);Code
if (customer.length == 0) {Code
$("table:last", row).remove(); } else {Code
$(".postal", row).eq(j).html(customer.find("ImageAssignedName").text());Code
$(".image", row).eq(j).attr("src", customer.find("ImagePath").text());Code
$(".image", row).eq(j).attr("alt", customer.find("ImagePath").text()); }Code
i++; }Code
$("[id*=dlCustomers]").append(row); }Code
$("[id*=dlCustomers] tr").eq(0).remove();Code
$("[id*=dlCustomers]").show(); }/*tried to display dropdown selected value images*/
Code
$(document).ready(function () {Code
$('#ddlColor').on('change', function () {Code
var color = $('#ddlColor :selected').text();Code
alert(color);Code
$("[id*=dlCustomers]").hide();Code
$.ajax({Code
type: "POST",Code
url: "Default2.aspx/GetColorFabrics",Code
data: "{'color':'" + color + "'}",Code
contentType: "application/json; charset=utf-8",Code
dataType: "json",Code
success: OnSuccessColor,Code
failure: function (response) {Code
alert(response.d); },Code
error: function (response) {Code
alert(response.d); } }); }); });Code
function OnSuccessColor(response) {Code
alert('hello');Code
alert(response.d);Code
var xmlDoc = $.parseXML(response.d);Code
var xml = $(xmlDoc);Code
var customers = xml.find("Table");Code
var repeatColumns = parseInt("");Code
var rowCount = Math.ceil(customers.length / repeatColumns);Code
var i = 0;Code
while (i repeatColumns * rowCount) {Code
for (var j = 0; j repeatColumns; j++) {Code
var customer = $(customers[i]);Code
if (customer.length == 0) {Code
$("table:last", row).remove(); }Code
else {Code
$(".postal", row).eq(j).html(customer.find("ImageAssignedName").text());Code
$(".image", row).eq(j).attr("src", customer.find("ImagePath").text());Code
$(".image", row).eq(j).attr("alt", customer.find("ImagePath").text()); }Code
i++; }Code
$("[id*=dlCustomers]").append(row); }Code
$("[id*=dlCustomers] tr").eq(0).remove();Code
$("[id*=dlCustomers]").show(); }

Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Sep 16, 2015, 9:43 PM EDT
Dawood AbbasRank #6,413 · 267 reputationPosted Sep 16, 2015, 9:53 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Sep 16, 2015, 9:58 PM EDT
Dawood AbbasRank #6,413 · 267 reputationPosted Sep 16, 2015, 9:59 PM EDT