Consuming a Web Service

We are consuming a web service designed on an AS400.  We are consuming this
via ASP.Net by defining a Service Reference.
We then use the following code


    wcfInput._PARMCUST = "   5709B"
    Dim wcfResult1 As WCSSHIPMNT.WCSSHIPMNTResult = wcfClient1.wcsshipmnt(wcfInput)

    DataGrid2.DataSource = wcfResult1._DSSHIPMENT

To bind the result to the datagrid.  

This works well, except I am not able to capture on the ItemDataBound event.  

I am not able to figure out how to bind this data to anything but the datagrid.
I would like it in a data adopter, or a data set.

Does anyone know how to do this?
LVL 13
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
You do not bind to a DataAdapter or a DataSet. A DataAdapter is used to load a DataSet (or DataTable), and a DataSet is an abstraction of a collection of related tables (generally). What are you trying to accomplish by using a DataSet?
I am not able to capture on the ItemDataBound event.  

What do you mean by this. ItemDataBound  always get fired after  DataGrid2.DataBind().

 Put a breakpoint on ItemDataBound   and see if code breaks there.
samic400Author Commented:
I want this data where I can use it,  where I can reference each field/data element individually or read thru it sequentially or sort it, then bind it to a control,  or select from it with a select statement
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Yes then in that case DataGrid2_ItemDatabound  is a proper location. Proceed with my suggestion. Put a break point there( does code break onDataGrid2_ItemDatabound? ).

samic400Author Commented:
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

I am then able to reference the data as  drv("FieldName")

end if

It does fire, I just don't know how to capture the data
OK does DataGrid has bound columns or also template coulmns?

If they are  Bound , you can read data like this:

e.Item.Cells(11).Text  '(column 10)

For a template column something like this:(If that cell contains a listbox)

Dim lst as ListBox

lst =e.Item.Cells(3).Controls(1)  'Gets the list box in coulmn 4 (assuming that cell has only 1 control inside it).

You may need to play with Cell and controls Indexs to find the correct location of the data you want.
samic400Author Commented:
before I load the data, I have to call another routine with the value of the cell and modify the data before loading the cell,  also I sometime check the value of the data coming in and then set a background color, so those options do not work,  How do I reference the data on the ItemDatabound event.
ItemDatabound happens exactly before data gets loaded to the grid.

data on itemdatabound are data in e. they are not on Grid yet so you should be able to modify them.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.