(Form Code)
Partial Class _Default
Inherits System.Web.UI.Page
ReadOnly Property OrderDate() As String
Get
Dim CurrentDate As Date
CurrentDate = Date.Now
Return CurrentDate
End Get
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
'Binding to ArrayList
'Dim ProductArrayList As ArrayList = New ArrayList()
'ProductArrayList.Add("Anise Seeds")
'ProductArrayList.Add("Bay Leaf")
'ProductArrayList.Add("Cinnamon")
'ProductArrayList.Add("Cassia")
'ProductArrayList.Add("Chives")
'ProductList.DataSource = ProductArrayList
'ProductList.DataBind()
'Binding to Hash Table
Dim ProductHashTable As Hashtable = New Hashtable()
ProductHashTable.Add("Anise Seeds", "Poo1")
ProductHashTable.Add("Bay Leaf", "Poo2")
ProductHashTable.Add("Cinnamon", "Poo3")
ProductHashTable.Add("Cassia", "Poo4")
ProductHashTable.Add("Chives", "Poo5")
ProductList.DataSource = ProductHashTable
ProductList.DataTextField = "Key"
ProductList.DataValueField = "Value"
ProductList.DataBind()
OrderDateBox.DataBind()
End If
End Sub
Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
MessageLabel.DataBind()
MessageLabel.Visible = True
End Sub
'method is created to illustrate binding control to method
Function CalculateDiscount() As Integer
If Val(QuantityBox.Text) >= 20 And Val(QuantityBox.Text) <= 50 Then
Return 20
ElseIf Val(QuantityBox.Text) > 50 Then
Return 30
Else
Return 0
End If
End Function
Protected Sub DiscountButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DiscountButton.Click
DiscountLabel.DataBind()
CalculateDiscount()
End Sub
Protected Sub AmtButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AmtButton.Click
AmountBox.DataBind()
End Sub
'(val(QuantityBox.text)* val(PriceBox.Text))-((val(DiscountLabel.Text)/100)* (val(QuantityBox.Text)*val(PriceBox.Text)))
End Class
No comments:
Post a Comment