解決 DropDownList 在控制項樣版中無法記錄狀態的問題
碰到一個怪怪的問題: 當 DropDownList 放在 GridView 的 HeaderTemplate 中時,PostBack 後就是無法記得上次選擇的項目 同樣的 DropDownList 移到外面後就一切正常了 解決辦法: 在 DropDownList.SelectedIndexChanged 事件中用 GridView.Attributes["MyIndex"] = DropDownList.SelectedIndex.ToString(); 的方式把選項記錄下來 在 GridView.RowDataBound 事件中用 DropDownList.SelectedIndex = Convert.ToInt32(GridView.Attributes["MyIndex"]); 的方式還原 緣由: 在 HeaderTemplate 製作條件過濾的下拉式選單 (VB.NET) (文章編號:N020600501)