User-1797368610 posted
I have DropDownLists on my page to select "Year" and when i am selecting the drop down value its displaying information into gridview. I am binding data in Page_Load event when (Not Page.IsPostBack). Users will select Year from the DropDownLists and
then will click on view or Edit link from the gridview go to a view/edit page. If they then select to 'Go Back' to the initial page from View/Edit page, the DropDownLists year always reset to the top of their alphabetical list or top value.
Is there any way this can be amended to remember the last values the user entered?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack() Then
fillddlyear()
filldatagriddetail("0", "0")
End If
End Sub
Private Sub fillddlyear()
Dim query As String
Dim lDataSet As System.Data.DataSet
Try
query = " select distinct to_char(maint_end_date,'yyyy') year " & _
" from maintenance_schedule " & _
" order by year "
lDataSet = PassDataSet("DBTS", query)
DdL_maintyear.DataSource = lDataSet
DdL_maintyear.DataTextField = "year"
DdL_maintyear.DataValueField = "year"
DdL_maintyear.DataBind()
Catch ex As Exception
'Lblexception.Text = ex.Message
End Try
End Sub
Private Sub filldatagriddetail(ByVal memberkey As String, ByVal transcnt As Integer)
Dim query, projno, bld_id As String
Dim lDataSet As System.Data.DataSet
Dim mytable As System.Data.DataTable
Dim totamt As Decimal = 0
Dim fnd As Boolean = False
Dim searchchar As String
searchchar = ":" ' Search for ":".
Try
query = "select rownum num,item_description, decode(vendor_id,null,' ',vendor_id) vendor_id, " & _
" decode(status,null,' ',status) status, estimated_amount, renewal_type, " & _
" to_char(maint_end_date,'dd-MON-yyyy') mntdate , to_char(status_date,'dd-MON-yyyy') status_date " & _
" from maintenance_schedule " & _
" where to_char(maint_end_date,'YYYY') = '" & DdL_maintyear.SelectedValue & "'" & _
" order by item_description "
lDataSet = PassDataSet("DBTS", query)
Session("projds") = lDataSet
mytable = lDataSet.Tables("ResultTable")
Dim dv As DataView = mytable.DefaultView
'if the user has elected to sort the gridview
If Not String.IsNullOrEmpty(Me.SortBy("GVdetail")) Then
'get the sort expression and apply it to our dataView
Dim sortExpr As String = Me.SortBy("GVdetail") & " " & IIf(Me.SortDirection("GVdetail") = WebControls.SortDirection.Ascending, "ASC", "DESC").ToString()
dv.Sort = sortExpr
End If
Me.GVdetail.DataSource = dv
Me.GVdetail.DataBind()
'Lblexception.Text = " "
Catch ex As Exception
If Trim(Mid(ex.Message, 1, 9)) = "ORA-01840" Then
'Lblexception.Text = "** Please enter a valid date. "
Else
End If
End Try
End Sub
