p0217859_05
asked on
DataGrid Problem
Hi all... I've got a problem.. i am trying to do a e-commerce application in Microsoft.NET web matrix program that will retrieve all the orders when i click on the button.
In my design mode, i have a datagrid and a button.
In the code mode, i inserted these codes:
-------------------------- ---------- ---------- ---------- -------
Sub Button1_Click(sender As Object, e As EventArgs)
Dim wsProxy as new IBuySpy.InstantOrder()
Dim userName As String
Dim password As String
Dim orderID As Integer
DataGrid.DataSource = wsProxy.CheckStatus(userNa me,passwor d,orderID)
DataGrid1.DataBind()
End Sub
-------------------------- ---------- ---------- ---------- --
I think i did not declare the variable correctly. Can anyone help me to correct it? I don't know how to make the page work...
Thanks lots..
In my design mode, i have a datagrid and a button.
In the code mode, i inserted these codes:
--------------------------
Sub Button1_Click(sender As Object, e As EventArgs)
Dim wsProxy as new IBuySpy.InstantOrder()
Dim userName As String
Dim password As String
Dim orderID As Integer
DataGrid.DataSource = wsProxy.CheckStatus(userNa
DataGrid1.DataBind()
End Sub
--------------------------
I think i did not declare the variable correctly. Can anyone help me to correct it? I don't know how to make the page work...
Thanks lots..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for ur quick response.
the datagrid can display items, but it displays everything i have that i extracted from the database.
this is what i have in the asmx page that i used to generate a proxy with.
<%@ WebService Language="VB" Class="InstantOrder" %>
Imports System
Imports System.Web.Services
Imports ASPNET.StarterKit.Commerce
Public class InstantOrder : Inherits WebService
'************************* ********** ********** **********
'
' InstantOrder.OrderItem() Method
'
' The OrderItem method enables a remote client to programmatically
' place an order using a webservice.
'
'************************* ********** ********** **********
<WebMethod(Description:="T he OrderItem method enables a remote client to programmatically place an order using a WebService.", EnableSession:=false)> _
Public Function OrderItem(ByVal userName As String, ByVal password As String, ByVal productID As Integer, ByVal quantity As Integer) As Integer
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce .Customers DB = New ASPNET.StarterKit.Commerce .Customers DB()
Dim customerId As String = accountSystem.Login(userNa me, ASPNET.StarterKit.Commerce .Security. Encrypt(pa ssword))
If customerId Is Nothing Then
Throw New Exception("Error: Invalid Login!")
End If
' Wrap in try/catch block to catch errors in the event that someone types in
' an invalid value for quantity
Dim qty As Integer = System.Math.Abs(quantity)
If qty = quantity And qty < 1000 Then
' Add Item to Shopping Cart
Dim myShoppingCart As ASPNET.StarterKit.Commerce .ShoppingC artDB = New ASPNET.StarterKit.Commerce .ShoppingC artDB()
myShoppingCart.AddItem(cus tomerId, productID, quantity)
' Place Order
Dim orderSystem As ASPNET.StarterKit.Commerce .OrdersDB = New ASPNET.StarterKit.Commerce .OrdersDB( )
Dim orderID As Integer = orderSystem.PlaceOrder(cus tomerId, customerId)
' Return OrderDetails
Return orderID
Else
' invalid input
Return Nothing
End If
End Function
'************************* ********** ********** **********
'
' InstantOrder.CheckStatus() Method
'
' The CheckStatus method enables a remote client to programmatically
' query the current status of an order in the Commerce System.
'
'************************* ********** ********** **********
<WebMethod(Description:="T he CheckStatus method enables a remote client to programmatically query the current status of an order in the ASPNETCommerce System.", EnableSession:=false)> _
Public Function CheckStatus(ByVal userName As String, ByVal password As String, ByVal orderID As Integer) As OrderDetails
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce .Customers DB = New ASPNET.StarterKit.Commerce .Customers DB()
Dim customerId As String = accountSystem.Login(userNa me, ASPNET.StarterKit.Commerce .Security. Encrypt(pa ssword))
If customerId = "" Then
Throw New Exception("Error: Invalid Login!")
End If
' Return OrderDetails Status for Specified Order
Dim orderSystem As ASPNET.StarterKit.Commerce .OrdersDB = New ASPNET.StarterKit.Commerce .OrdersDB( )
Return orderSystem.GetOrderDetail s(orderID, customerId)
End Function
<WebMethod> Function GetOrders() As System.Data.DataSet
Dim connectionString As String = "server='(local)'; user id='sa'; password='346Password'; database='Commerce'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlC onnection( connection String)
Dim queryString As String = "SELECT [CMRC_OrderDetails].[Order ID], [CMRC_OrderDetails].[Produ ctID], [CMRC_Cust"& _
"omers].[EmailAddress], [CMRC_Customers].[Customer ID], [CMRC_OrderDetails].[UnitC "& _
"ost], [CMRC_OrderDetails].[Quant ity], [CMRC_Customers].[FullName ], [CMRC_Custome"& _
"rs].[Password] FROM [CMRC_OrderDetails], [CMRC_Customers]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlC ommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlD ataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
End Class
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
using this, i managed to display all the items, however, i need to only display the username, password and orderID.
how do i declare the items i want to display?
the datagrid can display items, but it displays everything i have that i extracted from the database.
this is what i have in the asmx page that i used to generate a proxy with.
<%@ WebService Language="VB" Class="InstantOrder" %>
Imports System
Imports System.Web.Services
Imports ASPNET.StarterKit.Commerce
Public class InstantOrder : Inherits WebService
'*************************
'
' InstantOrder.OrderItem() Method
'
' The OrderItem method enables a remote client to programmatically
' place an order using a webservice.
'
'*************************
<WebMethod(Description:="T
Public Function OrderItem(ByVal userName As String, ByVal password As String, ByVal productID As Integer, ByVal quantity As Integer) As Integer
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce
Dim customerId As String = accountSystem.Login(userNa
If customerId Is Nothing Then
Throw New Exception("Error: Invalid Login!")
End If
' Wrap in try/catch block to catch errors in the event that someone types in
' an invalid value for quantity
Dim qty As Integer = System.Math.Abs(quantity)
If qty = quantity And qty < 1000 Then
' Add Item to Shopping Cart
Dim myShoppingCart As ASPNET.StarterKit.Commerce
myShoppingCart.AddItem(cus
' Place Order
Dim orderSystem As ASPNET.StarterKit.Commerce
Dim orderID As Integer = orderSystem.PlaceOrder(cus
' Return OrderDetails
Return orderID
Else
' invalid input
Return Nothing
End If
End Function
'*************************
'
' InstantOrder.CheckStatus()
'
' The CheckStatus method enables a remote client to programmatically
' query the current status of an order in the Commerce System.
'
'*************************
<WebMethod(Description:="T
Public Function CheckStatus(ByVal userName As String, ByVal password As String, ByVal orderID As Integer) As OrderDetails
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce
Dim customerId As String = accountSystem.Login(userNa
If customerId = "" Then
Throw New Exception("Error: Invalid Login!")
End If
' Return OrderDetails Status for Specified Order
Dim orderSystem As ASPNET.StarterKit.Commerce
Return orderSystem.GetOrderDetail
End Function
<WebMethod> Function GetOrders() As System.Data.DataSet
Dim connectionString As String = "server='(local)'; user id='sa'; password='346Password'; database='Commerce'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlC
Dim queryString As String = "SELECT [CMRC_OrderDetails].[Order
"omers].[EmailAddress], [CMRC_Customers].[Customer
"ost], [CMRC_OrderDetails].[Quant
"rs].[Password] FROM [CMRC_OrderDetails], [CMRC_Customers]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlC
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
End Class
--------------------------
using this, i managed to display all the items, however, i need to only display the username, password and orderID.
how do i declare the items i want to display?
CheckStatus returns a "getOrderDetails"...which you didn't post...but I'm going to assume it is just like "GetOrders" and returns a dataset...in which case if you wanted to use the same dataset and just pull one value into a textbox or something...you can try...
Dim ds As DataSet = New DataSet
ds = wsProxy.CheckStatus(userNa me,passwor d,orderID)
Dim strUsername As String = ds.Tables(0).Rows(0)("Full Name").ToS tring()
Dim ds As DataSet = New DataSet
ds = wsProxy.CheckStatus(userNa
Dim strUsername As String = ds.Tables(0).Rows(0)("Full
ASKER
thanks.. i solved it.. :D sorry took so long...
ASKER
i have this in a file called InstantOrder.asmx
<%@ WebService Language="VB" Class="InstantOrder" %>
Imports System
Imports System.Web.Services
Imports ASPNET.StarterKit.Commerce
Public class InstantOrder : Inherits WebService
'*************************
'
' InstantOrder.OrderItem() Method
'
' The OrderItem method enables a remote client to programmatically
' place an order using a webservice.
'
'*************************
<WebMethod(Description:="T
Public Function OrderItem(ByVal userName As String, ByVal password As String, ByVal productID As Integer, ByVal quantity As Integer) As Integer
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce
Dim customerId As String = accountSystem.Login(userNa
If customerId Is Nothing Then
Throw New Exception("Error: Invalid Login!")
End If
' Wrap in try/catch block to catch errors in the event that someone types in
' an invalid value for quantity
Dim qty As Integer = System.Math.Abs(quantity)
If qty = quantity And qty < 1000 Then
' Add Item to Shopping Cart
Dim myShoppingCart As ASPNET.StarterKit.Commerce
myShoppingCart.AddItem(cus
' Place Order
Dim orderSystem As ASPNET.StarterKit.Commerce
Dim orderID As Integer = orderSystem.PlaceOrder(cus
' Return OrderDetails
Return orderID
Else
' invalid input
Return Nothing
End If
End Function
'*************************
'
' InstantOrder.CheckStatus()
'
' The CheckStatus method enables a remote client to programmatically
' query the current status of an order in the Commerce System.
'
'*************************
<WebMethod(Description:="T
Public Function CheckStatus(ByVal userName As String, ByVal password As String, ByVal orderID As Integer) As OrderDetails
' Login client using provided username and password
Dim accountSystem As ASPNET.StarterKit.Commerce
Dim customerId As String = accountSystem.Login(userNa
If customerId = "" Then
Throw New Exception("Error: Invalid Login!")
End If
' Return OrderDetails Status for Specified Order
Dim orderSystem As ASPNET.StarterKit.Commerce
Return orderSystem.GetOrderDetail
End Function
<WebMethod> Function GetOrders() As System.Data.DataSet
Dim connectionString As String = "server='(local)'; user id='sa'; password='346Password'; database='Commerce'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlC
Dim queryString As String = "SELECT [CMRC_OrderDetails].[Order
"omers].[EmailAddress], [CMRC_Customers].[Customer
"ost], [CMRC_OrderDetails].[Quant
"rs].[Password] FROM [CMRC_OrderDetails], [CMRC_Customers]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlC
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
End Class
--------------------------
and using this, i created another aspx page, and created a proxy linked to the asmx page.
i now want to display username, password and orderID, but i am only able to everything that i extract from the database.
How do i specify the specific things i want to display?