Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
If Request.Cookies("classes") Is Nothing Then
Else
If Request.Cookies("classes").Value = "Admin" Then
DropDownList1.Items.Add("Admin")
DropDownList1.Items.Add("Doctor")
DropDownList1.Items.Add(New ListItem("Admins", "Admins"))
DropDownList1.DataBind()
ElseIf Request.Cookies("classes").Value = "Doctor" Then
DropDownList1.Items.Add("Custom")
DropDownList1.DataBind()
Else
Response.Redirect("error/error.aspx")
End If End If
End If
'在此处放置初始化页的用户代码
End Sub
If Not IsPostBack Then
If Request.Cookies("classes") Is Nothing Then
Else
If Request.Cookies("classes").Value = "Admin" Then
DropDownList1.Items.Add("Admin")
DropDownList1.Items.Add("Doctor")
DropDownList1.Items.Add(New ListItem("Admins", "Admins"))
DropDownList1.DataBind()
ElseIf Request.Cookies("classes").Value = "Doctor" Then
DropDownList1.Items.Add("Custom")
DropDownList1.DataBind()
Else
Response.Redirect("error/error.aspx")
End If End If
End If
'在此处放置初始化页的用户代码
End Sub
dropdownlist1.Datasource = dt
dropdownlist1.DataBind()
上面这样绑定到某个数据源才需要DataBind()如果是绑定到某个数据源后还要添加一些item,那么dropdownlist1.Items.Add应该跟在DataBind后面
就是 DropDownList1.Items.Add("Admin")
DropDownList1.Items.Add("Doctor")
这些好象没用啊....怎么回事/
但是既然lz说不行,那就改为DropDownList1.Items.Add(New ListItem("Admins", "Admins"))好了~