使用Jquery将数据库数据绑定到Gridview

时间:2014-06-09 06:49:18

标签: c# jquery asp.net ajax json

我使用Jquery将数据绑定到Gridview,On Checkbox选择更改我从数据库获取数据,当我尝试将这些数据传递给Jquery以绑定Gridview时显示{{ 1}}。

Error
Jquery
  

aspx.cs

 <script type="text/javascript">
     $(document).on('click', 'input', function () {
         var key = $(this).find('lb' + this.id).text();
         var val = 'lb' + this.id;
         var lbltext = document.getElementById(val).innerHTML;
         $.ajax({
             type: "POST",
             url: "CandidateManagement.aspx/BindDatatable",

             data: '{value: "' + lbltext + '" }',
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             success: function (details) {
                 alert(response.d.length);
                 for (var i = 0; i < response.d.length; i++) {

                     $("#gvUserManage").append("<tr><td>" + response.d[i].CandidateID + "</td><td>" + response.d[i].CandidateName + "</td><td>" + data.d[i].CurPosition + "</td></tr>" + "<tr><td>" + response.d[i].TotWorkExp + "</td><td>" + response.d[i].Skillset + "</td><td>" + data.d[i].USStatus + "</td></tr>" + "</td><td>" + data.d[i].Location + "</td></tr>" + "</td><td>" + data.d[i].ActiveResume + "</td></tr>");
                 }
             },
             error: function (result) {
                 alert("Error");
             }
         });
</script>

1 个答案:

答案 0 :(得分:1)

在你的jquery中,'response'你必须在成功函数中编写响应而不是细节

success: function (response) {
             alert(response.d.length);
             for (var i = 0; i < response.d.length; i++) {

          $("#gvUserManage").append("<tr><td>" + response.d[i].CandidateID + "</td>   <td>" + response.d[i].CandidateName + "</td><td>" + .d[i].CurPosition + "</td></tr>" + "<tr><td>" + response.d[i].TotWorkExp + "</td><td>" + response.d[i].Skillset + "</td><td>" + response.d[i].USStatus + "</td></tr>" + "</td><td>" + response.d[i].Location + "</td></tr>" + "</td><td>" + response.d[i].ActiveResume + "</td></tr>");
             }
         },