在列表视图中绑定数据

时间:2014-06-17 05:44:03

标签: c# javascript jquery ajax

我正在使用JQUERY从aspx.cs页面调用WebMethod函数并尝试在DIV中绑定这些值,但是在函数Jquery的返回值显示error消息之后..这个Jquery的错误是什么......

Jquery

<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;
          var names = [];
          $('input:checked').each(function () {
              names.push(this.id);
          });

          $.ajax(
                {

                    alert: alert(),
                    type: "POST",
                    url: "CandidateManagement.aspx/BindDatatablelist",
                    dataType: "json",
                    data: '{value: "' + names + '" }',
                    contentType: "application/json; charset=utf-8",
                    success: function (json) {
                        var output = $('#MyTemplate').parseTemplate(json);
                        $('#MyTemplateOutput').html(output);

                        //Add hover capabilities
                        $('tbody > tr').bind('mouseenter mouseleave', function () {
                            $(this).toggleClass('hover');
                        });
                    },
                                error: function (json) {
                                alert("Error");
                             }

                });

      });
 </script>

C# code

[WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static List<Admin_CandidateManagement> BindDatatablelist(string value)
    {

        Admin_CandidateManagement admincandi = new Admin_CandidateManagement();
        string strSrcQry = admincandi.getSrcQryExpr(value);

        DataTable dt = new DataTable();
        Recruitment recOBJ = new Recruitment();
        admincandi.recOBJ.GetAllCandiDeatForAdvaceSearch(ref admincandi.dsCandiDeat, strSrcQry);
        dt = admincandi.dsCandiDeat.Tables[0];

        List<Admin_CandidateManagement> details = new List<Admin_CandidateManagement>();
        foreach (DataRow dtrow in dt.Rows)
        {
            Admin_CandidateManagement user = new Admin_CandidateManagement();
         // user.CandidateID = dtrow["CandidateId"].ToString();
            user.CandidateName = dtrow["CandiName"].ToString();
            user.CurPosition = dtrow["CurrPosi"].ToString();
            user.TotWorkExp = dtrow["TotWrkExp"].ToString();
            user.Skillset = dtrow["SkillSet"].ToString();
            user.USStatus = dtrow["USStatus"].ToString();
            user.Location = dtrow["Location"].ToString() + "   " + dtrow["JobZipCode"].ToString();
            user.ActiveResume = dtrow["ActiveResume"].ToString();
            details.Add(user);
        }
        return details;
    }

0 个答案:

没有答案