记录未绑定到网格-使用asp.net剑道ui(非mvc)

h7wcgrx3  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(199)

我们使用的是asp.net剑道ui(不是mvc)。
我们引用这个链接来绑定网格中的记录。
对于ajax方法,我们调用了web上的代码隐藏(静态方法)。
我们正在获取datatable上的记录,将其更改为jsonconvert.serializeobject并将其返回到ajax。
返回的数据被解析并绑定到网格上。下面提到的代码片段供您参考。
jquery-ajax:

var gridDataSource = new kendo.data.DataSource({
transport: {
    read: function (options) {
        $.ajax({
            type: "POST",
            url: "History.aspx/BindGridDetails",
            data: JSON.stringify({ "FromDate": $("#ContentPlaceHolder1_tdpFromDate").val(), "ToDate": $("#ContentPlaceHolder1_tdpToDate").val(), "CategoryId": $("#ContentPlaceHolder1_ddlCategory option:selected").text(), "AccountId": $("#ContentPlaceHolder1_ddlAccount option:selected").val() }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                options.success(JSON.parse(response.d));
            }
        });
    }
},
});

c代码隐藏:

[WebMethod]
    public static string BindGridDetails(DateTime FromDate, DateTime ToDate, string CategoryId,int AccountId)
    {
        DataTable DT = new DataTable();

            int iOwnerID = Convert.ToInt32(HttpContext.Current.Session["OwnerID"]);
            string sErrorMessage = string.Empty;              

            SqlDataReader DR = null;
            DBClass DB = new DBClass();               

            if (DB.GetHistory(iOwnerID, AccountId, sCategoryID, ref DT, ref sErrorMessage, ref ToDate, ref FromDate) == false)
            {                 
                return sErrorMessage;
            }
        }
       return JsonConvert.SerializeObject(DT);
    }

数据库类:

public bool GetHistory(int iOwnerID, int iLocationID, string sCategory, ref DataTable DT, ref string sErrorMessage, ref DateTime toDate, ref DateTime fromDate)
    {
        DT = new DataTable();
        CreateNewCommand(CommandType.Text);
        {
            var withBlock = _cmd;
            withBlock.CommandText = "SELECT top(190) Cast(T.EDate AS Date) as CompDate, T.ID  AS TicketNumber, T.WorkOrder, L.Tag AS Account, " + "E.Unit, T.Cat, W.fDesc AS Mechanic, (T.Reg + T.OT + T.DT + T.NT) as Hours," + " CASE WHEN Charge = 1 or isnull(Invoice, 0) > 0 THEN '$' ELSE ' ' END AS Billable ,  T.fDesc AS ScopeOfWork, T.DescRes AS Resolution" + " FROM TicketD T  " + " INNER JOIN Loc L  ON T.Loc = L.loc  " + " INNER JOIN tblWork W ON T.fWork = W.ID  " + " LEFT JOIN Elev E ON  T.Elev=E.ID  " + " WHERE L.Owner = " + iOwnerID + GetHistoryWhere(iLocationID, sCategory) + " AND T.Internet = 1 AND EDate <= '" + toDate.Date + "' AND EDate >= '" + fromDate.Date + "'" + " ORDER BY T.EDate DESC";
            try
            {
                SqlDataAdapter DA = new SqlDataAdapter(_cmd);
                DA.Fill(DT);
            }
            catch (Exception X)
            {
                sErrorMessage = X.Message;
                RemoveAllParameters(ref _cmd);
                return false;
            }
            RemoveAllParameters(ref _cmd);
            return true;
        }
    }

如果我们得到top(100/150)记录,它在网格上的绑定是正确的,但是如果我们得到超过190条记录,我们就会得到错误。
下面提到的视频链接供您参考。如果您需要更多信息,请检查并告知我们。
视频链接

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题