1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
Sub newDropDownList(ByVal strName As String)
'Northwind Datenbank
Dim strSql As String = "SELECT * FROM Products"
'Webservice mit der Methode getDataSetSQL die einen ein DataSet zurückgibt
'zum ausprobieren umschreiben!
Dim ws As New WebService.Service
Dim ds As New System.Data.DataSet
Dim cbo As New DropDownList
ds = ws.getDataSetSQL(strSql, Session("strConnectionString"))
cbo.ID = "cboID" & strName
cbo.AutoPostBack = True
cbo.CssClass = "cboCssClass"
ds.Tables(0).Rows(0)(1) = "Not defined"
cbo.DataSource = ds.Tables(0).DefaultView
cbo.DataTextField = "ProductID"
cbo.DataValueField = "ProductName"
cbo.DataBind()
'Hinzufügen des Event Handler
AddHandler cbo.SelectedIndexChanged, AddressOf cbo_SelectedIndexChanged
End Sub
Protected Sub cbo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDistrict.SelectedIndexChanged
Response.Write(sender.ID)
End Sub
|