我需要从看起来像这样的 Web 服务返回一些数据:
data.page = 1
data.count = 12883
data.rows(0).id = 1
data.rows(0).name = "bob"
data.rows(1).id = 2
data.rows(1).name = "steve"
data.rows(2).id = 3
data.rows(2).name = "fred"
我不知道该怎么做。我已经返回简单类型和简单数组,但从来没有这样的对象。
数据源是一个sql数据库。目标是一个 javascript/ajax 函数。我目前成功地将行本身作为数据集返回并且它可以工作,但是我需要添加计数和其他几个“父级”变量。
为了充分披露,这里是有效的代码:
<WebMethod()> _
Public Function rptPendingServerRequests() As DataSet
Dim connetionString As String
Dim connection As SqlConnection
Dim command As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
connetionString = "..."
sql = "SELECT usm_request.request_id, usm_request.status, usm_request.req_by_user_id " +
"FROM usm_request " +
"WHERE usm_request.request_id in " +
"(SELECT distinct(usm_request.request_id) from usm_request, usm_subscription_detail WHERE usm_request.request_id = usm_subscription_detail.request_id " +
"AND usm_subscription_detail.offering_id = 10307) ORDER BY usm_request.request_id DESC"
connection = New SqlConnection(connetionString)
Try
connection.Open()
command = New SqlCommand(sql, connection)
adapter.SelectCommand = command
adapter.Fill(ds)
adapter.Dispose()
command.Dispose()
connection.Close()
Return ds
Catch ex As Exception
End Try
End Function
我正在尝试使用 FlexiGrid 来使用它。我已经工作了几个小时没有运气。我基本上需要将以下站点的 PHP 转换为 .net
http://code.google.com/p/flexigrid/wiki/TutorialPropertiesAndDocumentation