我如何从Web服务返回数据集并绑定.aspx页中的多个表 [英] How can i returned dataset From webservice and bind multiple tables in .aspx page

查看:64
本文介绍了我如何从Web服务返回数据集并绑定.aspx页中的多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何将数据集从Web服务返回到.aspx页并在.aspx页中绑定两个表.


我需要使用jquery ajax,json.


请帮我做.


在此先感谢

Dileep

Hi,

How can I return dataset from webservice to .aspx page and bind two tables in the .aspx page.


I need to use jquery ajax, json.


Please help me to do it.


Thanks in advance

Dileep

推荐答案

检查网址,
http://stackoverflow.com/questions/451460/datatable-to-json [ ^ ]

http://james.newtonking.com/pages/json-net.aspx [ ^ ]

其背后的基本思想是
1.从Web服务中的数据集中获取所有数据表对象
2.获取每个数据表的JSOn字符串
3.或者您可以将数据放入Dictionary< string,>
这是一个适合JSON字符串的代码
Check the url,
http://stackoverflow.com/questions/451460/datatable-to-json[^]

http://james.newtonking.com/pages/json-net.aspx[^]

The basic idea behind this is,
1. Get all datatable objects from dataset in webservice
2. Get the JSOn string for each datatable
3. Or you can get the data into Dictionary<string,>
Here is a code to convery to JSON string
public static string GetJSONString(DataTable Dt)
{

string[] StrDc = new string[Dt.Columns.Count];
string HeadStr = string.Empty;

for (int i = 0; i < Dt.Columns.Count; i++)
{

StrDc[i] = Dt.Columns[i].Caption;

HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";
}

HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);

StringBuilder Sb = new StringBuilder();
Sb.Append("{\"" + Dt.TableName + "\" : [");

for (int i = 0; i < Dt.Rows.Count; i++)
{

string TempStr = HeadStr;
Sb.Append("{");

for (int j = 0; j < Dt.Columns.Count; j++)
{

TempStr = TempStr.Replace(Dt.Columns[j] + j.ToString() + "¾", Dt.Rows[i][j].ToString());
}

Sb.Append(TempStr + "},");
}



希望这会有所帮助.
欢呼



Hope this helps.
cheers


这篇关于我如何从Web服务返回数据集并绑定.aspx页中的多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆