json binding to database

json binding to database

bijupranavambijupranavam Posts: 3Questions: 2Answers: 0

my json output looks like below one. I want to bind the "ItemName":"Guest Room

rate","LastUpdatedDate":"01-12-2016" fields to a datatable. Kindly help I am new to jquery

[{"ImportItemMasterId":0,"ItemName":"Guest Room

rate","ProtocolID":0,"ProtocolName":null,"ItemTypeName":null,"ItemID":0,"LastUpdatedDate":"01-12-2016"},

{"ImportItemMasterId":0,"ItemName":"Guest Room

Occupancy","ProtocolID":0,"ProtocolName":null,"ItemTypeName":null,"ItemID":0,"LastUpdatedDate":"11-01-2016"}]

Answers

  • SreejeshSreejesh Posts: 2Questions: 1Answers: 0
    edited January 2016

    Please use dynamic binding

  • bijupranavambijupranavam Posts: 3Questions: 2Answers: 0
    edited January 2016

    Hi,

    My json output

    [{"ImportItemMasterId":0,"ItemName":"Guest Room

    rate","ProtocolID":0,"ProtocolName":null,"ItemTypeName":null,"ItemID":0,"LastUpdatedDate":"01-12-2016"},

    {"ImportItemMasterId":0,"ItemName":"Guest Room

    Occupancy","ProtocolID":0,"ProtocolName":null,"ItemTypeName":null,"ItemID":0,"LastUpdatedDate":"11-01-2016"}]

    my code snippet is like

    $.ajax({

                url: 'DataImportAjax.aspx?Tablename=DataImportUploadedDetails&hotelId=' + $('#ddlHotel').val(),
    
                datatype: 'json',
    
                mtype: 'GET',
    
                cache: false,
    
                async: true,
    
                complete: function (jsondata, stat) {
    
                    if (stat == 'success') {
    
                        $('#sample').DataTable({
    
                            data: jsondata.responseText,
    
                            columns: [
                                { title: "ImportItemMasterId" },
                                { title: "ItemName" },
                                { title: "ProtocolID" },
                                { title: "ItemTypeName" },
                                { title: "ItemID" },
                                { title: "LastUpdatedDate" }
                            ]
                        });
                    }
                }
            });
    

    got this error !!!!!

    DataTables warning: table id=sample - Requested unknown parameter '1' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4

This discussion has been closed.