Click here to Skip to main content
14,879,397 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If I bind gridview on page_load, then search button client side event fired but gridview getting null at static webmethod OR Other method of same page called inside static webmethod.


my Jquery Method:

C#
function GetUserDetails() {debugger;
        
          var grdUserDetails = document.getElementById("ContentPlaceHolder1_grdUserDetails");
          if (ddlCities == null)
              ddlCities = 0;
          $.ajax({
              type: "POST",
              url: "UserDetails.aspx/UserListDetails",
              data: "{}"
              contentType: "application/json",
              dataType: "json",
              success: function (response) {// debugger;
                  // OnSuccess(response);
                  alert('success');
              },
              error: function (response) {
                  // debugger;
              }
          });
          return false;
      }


// web method //
 [WebMethod]
    public static List<usp_get_userview_details_test_result> UserListDetails() //,
    {  
        using (Pel_DataEntities1 objPelData = new Pel_DataEntities1())
        {
            grd = new GridView();
            var UserData = objPelData.USP_GET_USERVIEW_DETAILS_Test().ToList();
            UserDetails bb = new UserDetails(); // page class object
            //grdUser.DataSource = UserData;
            //grdUser.DataBind();
           // bb.grdUserDetails.DataSource = UserData;
          // bb.grdUserDetails.DataBind();
            //bb.Getmethod(UserData);
            
            grd.DataSource = UserData;
            grd.DataBind();
            bb.asddf(grd);
            return UserData;
        }
    }
 public void asddf(GridView gg)
    {
        grdUserDetails = gg;
       // grdUserDetails.DataBind();
    }</usp_get_userview_details_test_result>
Posted

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