-
Web Service returning dataset - invalid data src
This is my first attempt at using Web Services, and I've tested the actual web service which works via the Invoke button.
I'm getting the following error when trying to build a ddl from my web service dataset:
An invalid data source is being used for DropDownList1. A valid data source must implement either IListSource or IEnumerable.
The WebReference for the web service is called GetWBS.
The code for the calling page is:
**************************
**************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Create an instance of the Proxy class
Dim dsGetWBS As GetWBS.WBSValues
dsGetWBS = New GetWBS.WBSValues
DropDownList1.DataSource = dsGetWBS
DropDownList1.DataBind()
End Sub
I've added a Web Reference, GetWBS, and the code for the .asmx file is:
************************************************************
************************************************************
Public Class WBSValues
<WebMethod()> _
Public Function GetWBS() As DataSet
Dim DS As New DataSet
Try
sCon1.Open()
Dim strSQLType As String = "usp_SelectWBSNumberFromWBSDict"
Dim cmd As New SqlCommand(strSQLType, sCon1)
cmd.CommandType = CommandType.StoredProcedure
'Create the DataAdapter
Dim DA As New SqlDataAdapter
DA.SelectCommand = cmd
'Populate the DataSet and the connection
DA.Fill(DS, "WBSDict")
sCon1.Close()
Return DS
Catch ex As Exception
Throw ex ' = "Error Line 2928 Getting Types for SigAuth Datagrid: " & ex.Message
Finally
sCon1.Close()
End Try
End Function
End Class
-
I had to change this in the code behind for the calling page:
'Create an instance of the Proxy class
Dim dsGetWBS As GetWBS.WBSValues
dsGetWBS = New GetWBS.WBSValues
DropDownList1.DataSource = dsGetWBS.GetWBS
DropDownList1.DataTextField = Expr1
DropDownList1.DataValueField = [WBS Number]
DropDownList1.DataBind()
..but now, the DataTextField and the DataValueField are not right:
DropDownList1.DataTextField = Expr1 'Expr1 Not declared
DropDownList1.DataValueField = [IDNumber] 'Expression Expected
If I just do this for the code behind:
***
***
Dim dsGetWBS As GetWBS.WBSValues
dsGetWBS = New GetWBS.WBSValues
DropDownList1.DataSource = dsGetWBS.GetWBS
DropDownList1.DataBind()
...the code works, but the ddl says System.Data.DataRowView for each row
-
It would help if I put the "" around the values for the dataTextField and the DataValuefield, and from my original coce added ".Tables(0)" to the datasource.
I've used the following code and now have it working:
'Put user code to initialize the page here
'Create an instance of the Proxy class
Dim dsGetWBS As GetWBS.WBSValues
dsGetWBS = New GetWBS.WBSValues
DropDownList1.DataSource = dsGetWBS.GetWBS.Tables(0)
DropDownList1.DataTextField = "Expr1"
DropDownList1.DataValueField = "WBS Number"
DropDownList1.DataBind()
Similar Threads
-
Replies: 1
Last Post: 11-28-2005, 04:07 PM
-
Replies: 0
Last Post: 05-01-2003, 05:42 PM
-
By Steve Hiner in forum .NET
Replies: 7
Last Post: 04-22-2002, 09:19 PM
-
By Jawahar Rajan in forum Enterprise
Replies: 0
Last Post: 06-13-2001, 09:50 AM
-
By Dan Davis in forum .NET
Replies: 0
Last Post: 05-16-2001, 03:14 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks