我DropDownList
在 a 的标头中有 a GridView
,我将其数据绑定在 中RowDataBound
并将其放在UpdatePanel
. 我想在 selection(postback) 之后保留选定的值。如何 ?
在这里我填写下拉列表
Protected Sub gvStaffList_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) 处理 gvStaffList.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
' Fill the header dropdownlist from the datatable and displaying only the unique values (NOT from database directly)
' ============================= Supervisor name ======================================================
Dim ddlSupervisors As DropDownList = DirectCast(e.Row.FindControl("ddlSupervisors"), DropDownList)
For x As Integer = 0 To data.Rows.Count - 1
If ddlSupervisors.Items.FindByValue(data.Rows(x).Item("SuperId")) Is Nothing Then
ddlSupervisors.Items.Add(New ListItem(data.Rows(x).Item("SuperName"), data.Rows(x).Item("SuperId")))
End If
Next
ddlSupervisors.Items.Insert(0, New ListItem("All", "All"))
' ============================= Supervisor name ======================================================
Dim ddlPostTitle As DropDownList = DirectCast(e.Row.FindControl("ddlPostTitle"), DropDownList)
For x As Integer = 0 To data.Rows.Count - 1
If ddlPostTitle.Items.FindByValue(data.Rows(x).Item(1)) Is Nothing Then
ddlPostTitle.Items.Add(New ListItem(data.Rows(x).Item(1), data.Rows(x).Item(1)))
End If
Next
ddlPostTitle.Items.Insert(0, New ListItem("All", "All"))