使用Web服务数据构建Grdivew

时间:2015-01-21 17:00:32

标签: asp.net vb.net web-services

您好我正在尝试根据我的Web服务数据构建Gridview。

编译代码时我没有收到任何错误,但是gridview没有显示。不确定这是否是因为我正在构建gridview错误或数据没有被正确拉出。 Web服务确实有效,因为我已对其进行了测试。

以下是我用来绑定gridview的代码:

Private Sub BindGrid()
    Dim objVen As New ISISVendor.VendorInterfaceClient
    Dim LoginResp As New ISISVendor.LoginResponse
    Dim POResp As New ISISVendor.PoSummaryResponse
    Dim pod As New ISISVendor.PoDetailResponse

    Dim dt As New DataTable
    dt.Columns.Add("Status")
    dt.Columns.Add("Sender")
    dt.Columns.Add("PO Number")
    dt.Columns.Add("Date")
    dt.Columns.Add("Action")
    gvv.DataSource = dt

    POResp = objVen.GetOpenPos("3274")
    Dim dr As DataRow

    If POResp.Pos.Count > 0 Then


        For j As Integer = 0 To POResp.Pos.Count - 1
            dr = dt.NewRow
            dr.Item("Status") = POResp.Pos(j).Status
            dr.Item("Sender") = "COMPANY TEST"
            dr.Item("PO Number") = POResp.Pos(j).PoNumber
            dr.Item("Date") = POResp.Pos(j).PoDate
            dr.Item("Action") = ""


        Next
    End If
    gvv.DataBind()
End Sub

1 个答案:

答案 0 :(得分:0)

似乎您没有将数据行添加到数据表中 请尝试以下

POResp = objVen.GetOpenPos("3274")
Dim dr As DataRow

If POResp.Pos.Count > 0 Then


    For j As Integer = 0 To POResp.Pos.Count - 1
        dr = dt.NewRow
        dr.Item("Status") = POResp.Pos(j).Status
        dr.Item("Sender") = "COMPANY TEST"
        dr.Item("PO Number") = POResp.Pos(j).PoNumber
        dr.Item("Date") = POResp.Pos(j).PoDate
        dr.Item("Action") = ""

        dt.Rows.Add(dr)


    Next
End If
gvv.DataSource = dt
gvv.DataBind()