Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

How to create search function using Visual Web Developer 2005 Express Edition

I have created a page in Visual Web Developer 2005 Express Edition that displays the contents of a Access database. I would like to add a text box on this page that users could enter a name and search the database, it has over 7,000 records. How can I do that with this IDE?  Also, I have a drop down that is populated with last names from the database. When you drop down the list you can see the names, but if you select one of the names the page just refreshes instead of showing you the selected name.  Any help would be great. Thanks.
0
valicon
Asked:
valicon
  • 7
  • 4
1 Solution
 
kGeniusCommented:
for your first problem (filtering data in gridview) read this tutorial: http://www.exforsys.com/content/view/1652/265/

for your second problem add in code-behind in Page_Load procedure:
If Not Page.IsPostBack Then
  DropDownList1.DataBind
End If

in c#
if (! IsPostBack) {
   DropDownList1.DataBind();
}

hope this'll help
0
 
valiconAuthor Commented:
I went through the tutorial above and the query works when tested but when you enter a last name in the search box it does not work. Any idea on what is wrong?
0
 
valiconAuthor Commented:
I have got the search function working. However I do not see where to place the code you provided.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
kGeniusCommented:
The code but be placed in code-behind (in your blabla.aspx.vb or blabla.aspx.cs file)
In VB.NET:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  If Not Page.IsPostBack Then
    DropDownList1.DataBind
  End If
End Sub

in C#
protected void Page_Load(Object sender, EventArgs e) {
  if (! IsPostBack) {
     DropDownList1.DataBind();
  }
}
0
 
valiconAuthor Commented:
Okay let me try that. Concerning the search is there any way to add soundex to it?
0
 
valiconAuthor Commented:
This is the only thing in the blabla.aspx.vb file:

Partial Class _Default
    Inherits System.Web.UI.Page

End Class

I placed the code in there but I received an error.
0
 
kGeniusCommented:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  If Not Page.IsPostBack Then
    DropDownList1.DataBind
  End If
End Sub

You must replace DropDownList1 with the ID of your DropDownList...

WHat error do you recieve? Can you be more specific?
0
 
valiconAuthor Commented:
I placed the above code into the .vb file and the error I received was:

Server Error in '/wwwroot' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30001: Statement is not valid in a namespace.

Source Error:

 

Line 9:  
Line 10:
Line 11: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Line 12:   If Not Page.IsPostBack Then
Line 13:     DropDownList1.DataBind
 

Source File: C:\Inetpub\wwwroot\Default.aspx.vb    Line: 11


Do you have any suggestions on adding soundex to the search function?
0
 
kGeniusCommented:
Be sure you add Protected Sub Päge_Load etc... in a class
eg:

Namespace YOURNAMESPACE
Public Class YOURCLASSNAME

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  If Not Page.IsPostBack Then
    DropDownList1.DataBind
  End If
End Sub

End Class

End Namespace
0
 
valiconAuthor Commented:
The only code in my default.aspx.vb file is:

Partial Class _Default
    Inherits System.Web.UI.Page

End Class


placing the above code has no effect...
0
 
valiconAuthor Commented:
Please close this question and refund points. I used and IDE and created the search function from within that program.
0
 
NetminderCommented:
Closed, 500 points refunded.
Netminder
Site Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now