查看完整版本: [ASP.NET] DropDownList 小技巧
頁: [1]

isve 發表於 2016-4-22 08:49 PM

[ASP.NET] DropDownList 小技巧

DropDownList 插入值

一、插入值,並將索引指到第一筆
DropDownList2.DataBind()
DropDownList2.Items.Insert(0, New ListItem("----", ""))
DropDownList2.SelectedIndex = 0

***********************************************************************************

二、插入數值,1到10
For i As Double = 1 To 10
    DropDownList1.Items.Add(New ListItem(i.ToString, i.ToString))
    DropDownList2.Items.Add(New ListItem(i.ToString, i.ToString))
Next

以上兩種方法可以合起來一起使用,程式也將更具方便性
...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>
頁: [1]