zezu10 Posted December 12, 2006 Share Posted December 12, 2006 Hi guys, I currently have a web form which searches a SQL table, and fills a datagrid.My form currently has two searches, which I have a seperate textbox and button for each, however I am wanting to add more searches to my form, and therefore am looking for the best way to have just the one textbox and button, but allowing multiple searches?Would a dropdown list be a good way to get around this problem, and if so, what is the best way to exectute that way of working around my current problem? Link to comment Share on other sites More sharing options...
aspnetguy Posted December 12, 2006 Share Posted December 12, 2006 yes I would say a dropdownlist would be the best approach.You can check the DDL's Selected Value on button click to determine which search to do. Link to comment Share on other sites More sharing options...
zezu10 Posted December 12, 2006 Author Share Posted December 12, 2006 the problem I have is that I now have about 7 or 8 searches that I have to do, and am having problems figuring out how to activate different searches with what has been selected by the DDL.I'm filling the grid by doing; Sub FillGridReg() Dim GetDataset As New GeneralReaderQuery(Constants.DATACCESSLINK, _ "STOREDPROCNAME", _ "@au_parameter", _ txtSearch.Text) Me.GrdVehicles.DataSource = GetDataset.FetchDataSet1Param GrdVehicles.DataBind() End Sub So am I going to have to do various IF statements but also how am I going to change the parameter value when the DDL is select? Link to comment Share on other sites More sharing options...
aspnetguy Posted December 12, 2006 Share Posted December 12, 2006 If condition1 Then FillGridReg("param1")End IfIf condition2 Then FillGridReg("param2")End IfSub FillGridReg(param As String) Dim GetDataset As New GeneralReaderQuery(Constants.DATACCESSLINK, _ "STOREDPROCNAME", _ param, _ txtSearch.Text) Me.GrdVehicles.DataSource = GetDataset.FetchDataSet1Param GrdVehicles.DataBind()End Sub Link to comment Share on other sites More sharing options...
zezu10 Posted December 12, 2006 Author Share Posted December 12, 2006 hmmm, my stored procedure would have to be edited sufficiently then to try and make it pass the parameter through the search.i'll give it a try. Link to comment Share on other sites More sharing options...
aspnetguy Posted December 12, 2006 Share Posted December 12, 2006 first can you explain what your diffrent searches are? maybe it would be best to create a SP for each search and pass the SP name into the function aswell. Link to comment Share on other sites More sharing options...
zezu10 Posted December 12, 2006 Author Share Posted December 12, 2006 well my searches kinda vary, for example;RegNoChassisNoCustomerNameRegDateAt the moment I have a StoredProc for each search, with each of them passing a specific paramter, ie @au_regdate1 and @au_regno1At the moment I have all the searches working on one form, but that means I currently have 9 text boxes and buttons on my page.It don't look too purdy :/ALSOI have a form working on a webspace, but now when I try to use to it locally, I get a Parser Error? Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load type 'WebApplication1.VehicleSearchForm'.Source Error: Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="VehicleSearchForm.aspx.vb" Inherits="WebApplication1.VehicleSearchForm" %>Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">Line 3: <HTML> Any ideas? Link to comment Share on other sites More sharing options...
jesh Posted December 12, 2006 Share Posted December 12, 2006 At the moment I have a StoredProc for each search, with each of them passing a specific paramter, ie @au_regdate1 and @au_regno1At the moment I have all the searches working on one form, but that means I currently have 9 text boxes and buttons on my page.I have a search form on one of my pages whiches search through help tickets by either Reference #, Date, Email Address, or keyword search of the contents. I also chose the dropdown list route.In my codebehind (C#) I have a switch which detects the selected value of the dropdown list and then tells my search functions (I have more than one...but that doesn't matter) what stored procedure to use. This isn't exactly how I do it - I have a more OOP approach - but this conveys the idea:string procedure = String.Empty;switch(SearchType.SelectedValue){ case "RefNo": procedure = "DoSearchByReferenceNumber"; break; case "Date": procedure = "DoSearchByDate"; break; case "Email": procedure = "DoSearchByEmail"; break; case "Search": procedure = "DoSearchByKeyword"; break;}DoSearch(procedure, txtSearch.Text); Link to comment Share on other sites More sharing options...
zezu10 Posted December 13, 2006 Author Share Posted December 13, 2006 ok I fixed that small error I had, was a simple typo, grrrr.erm I would like to keep my code vb.net based as much as possible, I do understand your code tho, it's just trying to pass the individual storedproc names that I am currently having trouble with. Link to comment Share on other sites More sharing options...
zezu10 Posted December 14, 2006 Author Share Posted December 14, 2006 Done it. For anyone who has this problem ever...I did it by. Sub FillGridCustomerDetails() Dim MyParams As New ParamProperties MyParams.ParamName1 = "@au_customername1" MyParams.ParamVal1 = txtCustomerName.Text MyParams.ParamName2 = "@au_custadd1" MyParams.ParamVal2 = txtCustomerAdd1.Text Dim GetReader As New GeneralReaderQuery(Constants.dataccessname, "storedprocname") Me.GrdVehicles.DataSource = GetReader.FetchDataSet2Param(MyParams) Me.GrdVehicles.DataBind() End Sub Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now