Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  2.  
  3. Response.Cache.SetCacheability(HttpCacheability.NoCache)
  4.  
  5. If Page.IsPostBack = False Then
  6.  
  7. ' Fill Activity DDL
  8. Dim ActivitiesAdapter As New ActivitiesTableAdapters.ActivitiesTableAdapter
  9. Dim GetActivities As Activities.ActivitiesDataTable = ActivitiesAdapter.GetDataByOnPlantAndOrderType(OrderType, Plant)
  10.  
  11. If GetActivities.Rows.Count > 0 Then
  12. DDL_Activity_Name.Items.Clear()
  13.  
  14. Dim ActivityList As New List(Of ListItem)
  15. ActivityList.Add(New ListItem("Please select ..."))
  16.  
  17. For b = 0 To GetActivities.Rows.Count - 1
  18. Dim ActivityRow As Activities.ActivitiesRow = GetActivities(b)
  19. Dim ActivityName As String = Nothing
  20. Dim ActivityID As Integer = Nothing
  21. If ActivityRow.IsNull("ActivityName") = False Then
  22. ActivityName = ActivityRow.ActivityName
  23. End If
  24. If ActivityRow.IsNull("ActivityID") = False Then
  25. ActivityID = ActivityRow.ActivityID
  26. End If
  27. ' First goes the Name then the ID
  28. ActivityList.Add(New ListItem(ActivityName, ActivityID))
  29. Next
  30.  
  31. DDL_Activity_Name.DataSource = ActivityList
  32. DDL_Activity_Name.DataBind()
  33.  
  34. End If
  35.  
  36. End If
  37. End Sub
  38.  
  39. Protected Sub DDL_Activity_Name_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DDL_Activity_Name.SelectedIndexChanged
  40.  
  41. ' At load page I added for every item a text property (ActivityName), and a value property (ActivityID)
  42. Dim SelectedActivityID As String = Nothing
  43. SelectedActivityID = DDL_Activity_Name.SelectedItem.Value
  44.  
  45. Dim SelectedActivityName As String = Nothing
  46. SelectedActivityName = DDL_Activity_Name.SelectedItem.Text
  47.  
  48. End sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement