2010年11月8日 星期一

免除透過appendDataBoundItems的bug

當要在DropDownList中加入"請選擇"時可利用此方法免除透過appendDataBoundItems的bug。

程式碼如下:
protected void DropDownList1_DataBound(object sender, EventArgs e)
    {
              ((DropDownList)sender).Items.Insert(0,new ListItem("請選擇"));
    }

沒有留言:

張貼留言