microkarl
Well-known member
All, I am a VB.NET programmer so please excuse me if the question is kinda dumb. I have a Web Service and a web page to call and retrieve data from the web serivce and pop them into a datagrid, the code is as follow:
If I have to do the exact same thing in C#, how to do it? I know C# is more strict on using delegates and need to declare the delegate functions first before using... can anyone help!
Thanks,
Carl
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objWS As New NorthWindWS.Products
Try
If Not Page.IsPostBack Then
objWS.BeginRetrieveAllProducts(New AsyncCallback(AddressOf RetrieveData_CallBack), objWS)
Else
lblError.Visible = False
lblError.Text = String.Empty
End If
Catch ex As Exception
lblError.Visible = True
lblError.Text = ex.ToString
End Try
End Sub
Private Sub RetrieveData_CallBack(ByVal ar As System.IAsyncResult)
Dim dsTemp As New DataSet
Dim ws As NorthWindWS.Products = CType(ar.AsyncState, NorthWindWS.Products)
dsTemp = ws.EndRetrieveAllProducts(ar)
With dgProducts
.DataSource = dsTemp.Tables(0)
.DataBind()
End With
End Sub
End Class
If I have to do the exact same thing in C#, how to do it? I know C# is more strict on using delegates and need to declare the delegate functions first before using... can anyone help!
Thanks,
Carl