标题表示我的问题。
我使用的Api(垂直响应,电子邮件列表管理器)工作正常。但是对于一个特定的方法返回一个数组,其中我需要引用的信息在该数组内的字典内。
数组[list_id,list_name,list_type,member_data]< - member_data是包含我所有好东西的字典。
我设法得到的最好的是列表框输出" com.verticalresponse.api.NVPair []"对于每个成员。
代码
Protected Sub GetBounces()
Dim listID As Integer = 284662333
Dim isMember As Boolean = False
Dim newSession As New loginArgs()
newSession.username = username
' Your VerticalResponse username
newSession.password = password
newSession.session_duration_minutes = "120"
Dim VRUser As New VRAPI()
Try
sessionID = VRUser.login(newSession)
Dim GetMembers As New getListMembersArgs()
Try
GetMembers.session_id = sessionID
GetMembers.list_id = listID
GetMembers.max_records = 8
Try
Dim listmembers As Array = VRUser.getListMembers(GetMembers)
lstBounces.DataSource = listmembers
lstBounces.DataValueField = ("member_data").ToString()
lstBounces.DataBind()
Catch ex As Exception
lstBounces.Text = "One: " + ex.ToString()
End Try
Catch listex As Exception
lstBounces.Text = "Two: " + listex.ToString()
End Try
Catch ex As System.Exception
lstBounces.Text = "Three: " + ex.ToString()
End Try
End Sub
修改
我采纳了 Keith Mifsud 的建议,并在Databind之前添加了一个断点。它告诉我" listmembers"有八个指数(目前只通过搜索8个进行测试(总列表将接近8000个,其中大约需要1900个。)
这8个索引中的每一个都包含我正在查看的4列,所以当我使用listmembers(3)作为数据源时,我真的只搜索第四个结果,而不是member_data列......
是否有正确的方法来引用结果列?
类似的东西:
lstbounces.DataSource = listmembers( ,3)
但不是那样,一个正确的吗?
答案 0 :(得分:1)
我认为您应该将数据源设置为字典,而不是将数据源设置为
Try
Dim listmembers As Array = VRUser.getListMembers(GetMembers)
lstBounces.DataSource = listmembers(3)
'As the datasource is a dictionary, I don't think you have to set up the display and value fields
'lstBounces.DataValueField = ("member_data").ToString()
lstBounces.DataBind()
Catch ex As Exception
lstBounces.Text = "One: " + ex.ToString()
End Try
<强>更新强>
根据集合类型(数组的每个元素中的字典),我建议你使用.net DataView,允许可扩展的行。有一些非常好的教程可以指导您创建视图