嗨我想从数据库中检索经度和纬度并将其保存到隐藏字段中。没有colomn名称的javascript序列化
表dt的从数据库中检索
latitude longitude
19.2094000000 73.0939000000
19.2244070000 73.1545760000
19.1659242536 82.2436523438
18.3336694458 80.4309082031
我使用的JavaScript序列化将其保存在隐藏字段
JavaScriptSerializer oSerializer = new JavaScriptSerializer();
var Result = (from c in dt.AsEnumerable()
select new
{
Latitude = c.Field<Decimal>("Latitude"),
Longitude = c.Field<Decimal>("Longitude")
}).ToList();
hdnControl.Value = oSerializer.Serialize(Result);
这导致到
[
{"Latitude":19.2094000000,"Longitude":73.0939000000},
{"Latitude":19.2244070000,"Longitude":73.1545760000},
{"Latitude":19.1659242536,"Longitude":82.2436523438},
{"Latitude":18.3336694458,"Longitude":80.4309082031}
]
,但我不希望结果数据中的列名称,因为我需要进一步处理它并从中提取经纬度。
如何在没有列名的隐藏字段中保存数据,所以数据看起来像这样?
[
{19.2094000000,73.0939000000},
{19.2244070000,73.1545760000},
{19.1659242536,82.2436523438},
{18.3336694458,80.4309082031}
]
你的目标是不是有效的JavaScript,或许是θ,λ值应在阵列而非实物。 – RobG
哇,thanx很多,这给了我新的方法,并在JavaScript数组是可访问的 –
thnx很多robG –