保持dropdownlist選中值

2021-04-28 04:00:15 字數 451 閱讀 7411

rowdatabound事件

protected void gridview1_rowdatabound(object sender, gridviewroweventargs e)

}e.row.attributes["style"] = "cursor:hand";

//問題分類下拉框繫結選中值

if (((dropdownlist)e.row.findcontrol("ddlprovar")) != null)

///

/// 儲存選定的dropdownlist值

///

///

///

private void setselecteditem(system.web.ui.webcontrols.listcontrol list, string value)

else e.selected = false;}}

擴充套件DropDownList

使用dropdownlist,我們習慣在所有待選資料前面加乙個空白項,或者 請選擇 的提示,微軟卻沒有,這可能就是中西文化的差異.現在擴充套件為dropdownlistpro 經過 除錯,和看源 得知預設選中的行為是在selectedindex的get方法中設定的.所以過載該方法,即可達到目的.pu...

dropdownlist資料繫結

在web.config配置檔案連線資料庫 新建乙個 sqlhelp 類 string scon system.configuration.configurationmanager.connectionstrings scon connectionstring 執行查詢的方法返回的是乙個dataset...

DropDownList使用總結

code 1 5g 若selectedvalue沒有對應的5g,則丟擲如下異常 dropdownlist1 有乙個無效 selectedvalue,因為它不在專案列表中。引數名 value 2 president 是設定索引中最小項的值為president,並不是選擇文字為president的項 3...