Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
unable to bind data in label after getting response from webmethod in json format

What I have tried:

JavaScript
$.ajax({
               type: "POST",
               url: '/Account/Account_Details.aspx/Datafordownload',
               data: "{'Transactionid':'" + arg + "'}",
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: function (response) {
                   var result = JSON.parse(response.d);
                   var a = result["Data"][0]["CompanyName"];
                   $('#lbl_companyname').text(a);
                   $('#lbl_address').html(result["Data"][0]["Address"]);
                   $('#lbl_city').html(result["Data"][0]["CityName"]);
                   $('#lbl_state').html(result["Data"][0]["StateName"]);
                   $('#lbl_zipcode').html(result["Data"][0]["ZipCode"]);
                   $('#lbl_email').html(result["Data"][0]["EmailId"]);
                   $('#lbl_transc_date').html(result["Data"][0]["StartDate"]);
                   $('#lbl_transtype').html(result["Data"][0]["TransactionDescription"]);
                   $('#lbl_desc').html(result["Data"][0]["Description"]);
                   $('#transactiondate').html(result["Data"][0]["StartDate"]);
                   $('#lbl_accountbalance').html(result["Data"][0]["NetBalance"]);
                   $('#lbl_credit').html(result["Data"][0]["Credit"]);
               },
               failure: function (response) {
                   alert(response.d);
               }
           });
Posted
Updated 9-Sep-16 0:44am
v2

try result[0].Name like this rather than result["Data"][0]["Name"
 
Share this answer
 
Comments
Member 12729432 9-Sep-16 5:18am    
result["Data"][0]["Name"] is giving the text but it is not binding to label. this is main issue and on label also i have used clientidmode ="static"
Vincent Maverick Durano 9-Sep-16 7:15am    
Are these controls reside within a DataBound control? Note that if you assign Static to a Databound control like a list child controls in templates do not get unique IDs either, so for list controls where you rely on unique Id for child controls you’ll probably want to use Predictable rather than Static.
try like this

JavaScript
$("#<%= lbl_address.ClientID %>").text('your text');
 
Share this answer
 

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