0

I want to bind grid view using jquery, As per procedure i completed all steps. And while debugging i can see my web method returning value and in browser also i can see all data are appearing as expected, but don't know why my grid is not visible? It seems am binding grid view dynamically so might be it wount visible on browser console windows, but after binding my grid is not rendering on Page

where I am doing mistake?

Jquery

var AllData = [];
function load_Data() {
    //debugger;
    var params = { AssetCode: $("#txtAssetCode").val(), SerialNumber: $("#txtSerialNumber").val(), LocationCode: $('#ddlLocation').val() };
    $.ajax({
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(params),
        url: 'NewAssetsTransactionWithoutMAsterPage.aspx/Get_Data',
        dataType: "json",
        async: false,
        success: function (result) {
            alert(result.d.length);
            for (var i = 0; i < result.d.length; i++) {

                $("[id*=grdViewRecordNewAssetsTransaction]").append("<tr><td>" + result.d[i].ASSETS + "</td><td>" + result.d[i].SERIAL_NUMBER + "</td></tr>" + "</td><td>" + result.d[i].LOCATION + "</td></tr>" + "</td><td>" + result.d[i].STATUS + "</td></tr>" + "</td><td>" + result.d[i].REMARK + "</td></tr>" + "</td><td>" + result.d[i].CREATEDBY + "</td></tr>");
            }
            FunctionalData(result.d)
            OnSuccessFunctionalCall();
        },
        error: function (err) { // Added this event to capture the failed requests.
            console.log(err);
        }
    });

    function FunctionalData(pdata) {
        AllData = pdata;
    }
    function OnSuccessFunctionalCall(data, status) {
        result = AllData;
        $("[id*=grdViewRecordNewAssetsTransaction]").append("<tr><th>ASSETS </th><th>SERIAL_NUMBER </th></tr> </th><th>LOCATION </th></tr> </th><th>STATUS </th></tr> </th><th>REMARK </th></tr> </th><th>CREATEDBY </th></tr>")
        for (var i = 0; i < result.length; i++) {
            debugger;
            $("[id*=grdViewRecordNewAssetsTransaction]").append("<tr><td>" + result[i].ASSETS + "</td><td>" + result[i].SERIAL_NUMBER + "</td></tr>" + "</td><td>" + result[i].LOCATION + "</td></tr>" + "</td><td>" + result[i].STATUS + "</td></tr>" + "</td><td>" + result[i].REMARK + "</td></tr>" + "</td><td>" + result[i].CREATEDBY + "</td></tr>")
        };
    }
    return false;
};

web method :

 [WebMethod]
    public static List<Info> Get_Data(string AssetCode, string SerialNumber, string LocationCode)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["FAV-VAConnectionStringDB"].ConnectionString);
        DataTable dt = new DataTable();
        conn.Open();
        SqlCommand cmd = new SqlCommand("Search_NewAssetsTransaction", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@P_ASSET_CODE", AssetCode);
        cmd.Parameters.AddWithValue("@P_SERIAL_NUMBER", SerialNumber);
        cmd.Parameters.AddWithValue("@P_LOCATION_CODE", LocationCode);
        var d = cmd.ExecuteReader();
        dt.Load(d);
        List<Info> list = new List<Info>();
        Info info;
        foreach (DataRow dr in dt.Rows)
        {
            info = new Info(dr["Assets"].ToString(), dr["SERIAL_NUMBER"].ToString(), dr["Location"].ToString() , dr["Status"].ToString() , dr["Remark"].ToString() , dr["CreatedBy"].ToString());
            list.Add(info);
        }
        conn.Close();
        return list;
    }

For holding complex type data i used Classes :

public class Info
    {
        public Info(string Assets, string Serial_number, string Location, string Status, string Remark, string CreatedBy)
        {
            this. ASSETS = Assets;
            this.SERIAL_NUMBER = Serial_number;
            this.LOCATION = Location;
            this.STATUS = Status;
            this.REMARK = Remark;
            this.CREATEDBY = CreatedBy;
        }
        public string ASSETS
        {
            get;
            set;
        }
        public string SERIAL_NUMBER
        {
            get;
            set;
        }

        public string LOCATION
        {
            get;
            set;
        }

        public string STATUS
        {
            get;
            set;
        }
        public string REMARK
        {
            get;
            set;
        }
        public string CREATEDBY
        {
            get;
            set;
        }
    }
4
  • OnSuccessFunctionalAreaCall(data, status) requires 2 parameters...but you are calling it with no parameters. "OnSuccessFunctionalAreaCall();" Commented Feb 16, 2021 at 18:49
  • You mean i need to change from OnSuccessFunctionalAreaCall(data, status) to only OnSuccessFunctionalAreaCall() am i right sir ? Commented Feb 16, 2021 at 18:53
  • no, you need the applicable parameters to pass into the function Commented Feb 16, 2021 at 18:55
  • But Suppose if this is the cause then data should not be populate in array right but here data are populating as expected Commented Feb 16, 2021 at 19:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.