I have a DropDownList in a header of a GridView and I bind its data in the RowDataBound and place it in the UpdatePanel . I want to retain the selected value after selection(postback) . how ?
here I fill in the dropdownlist
Protected Sub gvStaffList_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles 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"))
hello use session like that:
on c#
😉