|
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents txtKeyword As System.Web.UI.WebControls.TextBox
Protected WithEvents txtMode As System.Web.UI.WebControls.TextBox
Protected WithEvents lblKeywordSearch As System.Web.UI.WebControls.Label
Protected WithEvents lblKeyword As System.Web.UI.WebControls.Label
Protected WithEvents lblMode As System.Web.UI.WebControls.Label
Protected WithEvents Search As System.Web.UI.WebControls.Button
Protected WithEvents Datagrid1 As System.Web.UI.WebControls.DataGrid
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
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
End Sub
Private Sub Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Search.Click
' Variable to Store the Token Key
Dim TokenKey As String
' Declare variable for the amazon search service object
Dim Service As Amazon.AmazonSearchService = New _
Amazon.AmazonSearchService()
'Declare variable for KeywordRequest which is the object
'for the search request
Dim keyword As Amazon.KeywordRequest = New _
Amazon.KeywordRequest()
' Declare variable for the amazon Search Result
Dim ProductInformation As Amazon.ProductInfo
' Please Type your token key here
TokenKey = "XXXXXXXXXXXXXXXX"
'Fill in the properties of the keyword request
keyword.keyword = txtKeyword.Text 'what you are searching
keyword.mode = txtMode.Text 'amozon product line
keyword.page = 1 'page you want
keyword.tag = "webservices-20" 'affiliate tag
keyword.type = "lite" 'lite or heavy type
keyword.devtag = TokenKey 'token key
'Initiate the search
ProductInformation = Service.KeywordSearchRequest(keyword)
'Transform productInformation to DataSet
Datagrid1.DataSource = TransformToDataSet(ProductInformation)
Datagrid1.DataBind()
End Sub
'Transforms ProductInfo to DataSet
Function TransformToDataSet(ByVal productInfo As Amazon.ProductInfo) _
As DataSet
'Create the instance of dataset
Dim ds As DataSet = New DataSet()
'Create the headers
ds.Tables.Add("ListedProducts")
ds.Tables(0).Columns.Add("Image")
ds.Tables(0).Columns.Add("ProductName")
ds.Tables(0).Columns.Add("Authors")
ds.Tables(0).Columns.Add("Price")
'Get the Details object collection from
'productInfo object
Dim detailsCollection() As Amazon.Details = _
productInfo.Details
'Declare variables to be used in iteration
Dim details As Amazon.Details
Dim datarow As DataRow
'Iterate through detail object and
'get its properties
For Each details In detailsCollection
datarow = ds.Tables("ListedProducts").NewRow
datarow("Image") = details.ImageUrlSmall.ToString()
datarow("ProductName") = details.ProductName.ToString()
datarow("Authors") = details.Authors(0).ToString()
datarow("Price") = details.ListPrice.ToString()
ds.Tables("ListedProducts").Rows.Add(datarow)
Next
Return ds
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Architects softwares with emerging technologies that will save time and increase productivity.