Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls getting reset

Status
Not open for further replies.

s2001

Programmer
Dec 7, 2001
132
US
Hello,

I have a search page (in ASP.NET - codebehind in vb.net) with a text and combo box. User can pick the search criteia and enter search text in the text box and click on search button.

What's happening is once the user click on the search button, the system performs the search and shows the result in the datagrid on the same page. But all the search criteria gets reset.

Does any body know how to maintain the search text and selection information user has entered?

I have made sure that the enableviewstate on all the controls on the form is set to true. I have code check for ispostback. (If Not Page.IsPostBack Then..perform stuff)

If you need any more information, i would be glad to furnish it.

Thanks a lot for your help.

Thanks,
MB
 
Thanks for the reply jim. There's nothing much to code...

----------------------------------------------------------

Private Sub imgSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgSearch.Click


DoSearch(m_Filter)
end sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cmdSelectOperator.Attributes.Add("onclick", "javascript:return OpenDialog();")
cmdSelectfldName.Enabled = lstfldName.Items.Count > 0

If Not Page.IsPostBack Then
FillFieldNames()
ProcurementGrid.RowHighlightColor = Color.FromArgb(239, 251, 140) 'Color.FromArgb(209, 248, 248)
ProcurementGrid.RowClickEventCommandName = "View"
imgSearch.ImageUrl = "images\btn_medsearch.gif"
Search.NavigateUrl = "#"
imgNewProc.ImageUrl = "images\btn_mednewproc.gif"
NewProc.NavigateUrl = "#"
imgAdvSearch.ImageUrl = "images\btn_medbuildSrc.gif"
AdvSrc.NavigateUrl = "#"
imgClrSrc.ImageUrl = "images\btn_medclrSrc.gif"
clrSrc.NavigateUrl = "#"
End If
End Sub

Thanks,
MB
 
What does DoSearch() and FillFieldNames() do? Where are the textboxes, etc that get filled with search criteria?
Can you post the code of the 2 funtions above?
 
thanks for the response..

Public Function GetFieldNames(ByRef listbox As Web.UI.WebControls.ListControl, ByVal tableName As String)

listbox.Items.Clear()
tableName = tableName.Trim
If tableName = "" Then
Exit Function
End If

Try
Const strSQL As String = "GetFieldNames"
Dim sqlconn As New SqlClient.SqlConnection(CONN)
Dim cmd As SqlClient.SqlCommand = sqlconn.CreateCommand
Dim ds As New Data.DataSet
Dim da As New SqlClient.SqlDataAdapter '(strSQL, sConn)

cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = strSQL
cmd.Parameters.Add(New SqlClient.SqlParameter("@tableName", SqlDbType.VarChar))
cmd.Parameters("@tableName").Value = tableName
sqlconn.Open()
da.SelectCommand = cmd
da.Fill(ds, "FLD")
listbox.DataSource = ds.Tables("FLD").DefaultView
listbox.DataTextField = "name"
listbox.DataBind()
Catch ex As Exception
Console.Write(ex.Message)
End Try

End Function

The search function returns a dataset filled with the search results. Grid on the form is tied to the result.

Thanks,
MB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top