Ajax取值

/// <summary>
/// DataTable转为json
/// </summary>
/// <param name="dt">DataTable</param>
/// <returns>json数据</returns>
public static string ToJson(DataTable dt)
{
List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
try
{
foreach (DataRow dr in dt.Rows)
{
Dictionary<string, object> result = new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
result.Add(dc.ColumnName, dr[dc]);
}
list.Add(result);
}
}
catch (Exception ex)
{
LogInfo logInfo = new LogInfo("", "DataTable转为json", "Utility.cs页面的ToJson", ex);
logInfo.CreateExceptionLogFile(ex);
}

return SerializeToJson(list);
}


//获取TimeSheet整个数据
public void getTimeSheetTable()
{
string guid = Request.QueryString["guid"].ToString();
TimeSheetBLL TimeSheetBLL = new TimeSheetBLL();
DataTable dt=TimeSheetBLL.getTimeSheetTable(guid);
Response.Write(Utility.ToJson(dt));
Response.End();
}
function TimeSheetTable(guid) {
var model = "";
$.ajax(
{
type: "post",
cache: false,
async: false,
url: "../../web/pages/AjaxPages/GetInitDataController.aspx?Actions=getTimeSheetTable&guid=" + guid,
success: function (d, s) {
if (d != null) {
model = $.parseJSON(d);

}
}
});
return model;
}

转载于:https://www.cnblogs.com/illegal/p/6374243.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值