This is the webmethod with ajax and jquery. when the EmpID is like 123,12,123456 it open the popup box and show the output as i want but when EmpID is like A001,ABC it show the error like "Error while retrieving data of :" how to solve... Thanks in Advance
Query Data:-
JavaScript
$(document).on("click", ".editButton", function () {JavaScript
$("#myModal").focus(); var id = $(this).attr("data-id");Code
console.log(id);Code
$("#btnUpdate").attr("edit-id", id); //alert(id);Code
$.ajax({Code
type: "Post",Code
contentType: "application/json; charset=utf-8",Code
url: "Default3.aspx/EditData",Code
data: '{eid: ' + id + '}',Code
dataType: "json",Code
success: function (data) { var empDetails = $.parseJSON(data.d);Code
$.each(empDetails, function (index, value) {Code
$("#FirstName1").val(value.EmpID);Code
$("#MiddleName1").val(value.EmpName);Code
$("#Surname1").val(value.EmpAddress); //alert("hi"); }); },Code
error: function () {Code
alert("Error while retrieving data of :" + id); } }); }); });Html Table:-
Code
div class="row">Code
div class="col-lg-12"> br /> br />Code
div class="col-lg-12"> div class="panel panel-default">Code
div class="panel-heading"> Admin Employee Details Tables div>Code
div class="panel-body"> div class="dataTable_wrapper">Code
div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">Code
div class="row"> div class="col-sm-6">Python
div class="dataTables_length" id="dataTables-example_length"> Show select name="dataTables-example_length" aria-controls="dataTables-example" class="form-control input-sm" id="select">VB.NET
option value="5">5option> option value="10">10option>VB.NET
option value="25">25option> option value="50">50option>Code
option value="100">100option> select>Python
entrieslabel> div> div> div class="col-sm-6"> div id="dataTables-example_filter" class="dataTables_filter"> Search:input type="search" class="form-control input-sm" placeholder="" aria-controls="dataTables-example" id="searchtxt" />label> div> div> div> div class="row"> div class="table-responsive">Python
table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer " role="grid" aria-describedby="dataTables-example_info">Code
tr role="row">TypeScript
th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 175px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">Emp IDth> th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 203px;" aria-label="Browser: activate to sort column ascending">Emp Nameth> th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 184px;" aria-label="Platform(s): activate to sort column ascending">Emp Addressth> tr> thead> for (var data = 0; data TableData.Rows.Count; data++) { %> tr class="gradeA odd " role="row"> td class="sorting_1"> TableData.Rows[data]["EmpID"]%> td> TableData.Rows[data]["EmpName"]%> td> TableData.Rows[data]["EmpAddress"]%> td> input type="button" class="btn btn-primary editButton" data-id="EmpID"] %>" data-toggle="modal" data-target="#myModal" name="submitButton" id="btnEdit" value="Edit" /> td> input type="button" class="btn btn-primary deleteButton" data-id="EmpId"] %>" name="submitButton" id="btnDelete" value="Delete" /> td> tr> } %> tbody> table> div> div> div> div> /.table-responsive --> div> /.panel-body --> div> /.panel --> div> div> div>C# Code- Code Code Code Code Code Code Code Code Code Code Code Code Code |
Ajay MalikRank #752 · 3.1K reputationPosted Aug 21, 2016, 8:24 PM EDT
FirstName may not map to EmpID well. Middlename to EmpName, etc.
But overall, it sounds like something is expecting an integer input and you're giving it letters. Look for that and either change the input expectation to varchar/string or change the input to only consist of numbers.
Ravi PatelRank #439 · 5.7K reputationPosted Aug 21, 2016, 9:13 PM EDT
if it is object only then no need $.each() you can directly print the value data.propertyName this property exactly match suppose propertyname is FirstName then print the vlaue like data.FirstNameBikesh SrivastavaRank #108 · 20.3K reputationPosted Aug 21, 2016, 9:44 PM EDT
Vinay SinghRank #604 · 4K reputationPosted Aug 22, 2016, 12:24 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Aug 22, 2016, 12:26 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts