![]() |
Database Search Page
Hi All
I am attempting to create a web page using Visual Studio to search the "products" table in my local SQL Database. I have used a Gridview control to display the results from four drop down menus which are price, brand, colour and screen size. Ive managed to make the brand and colour menus to work, affecting the results of the Gridview, but I cannot make the others work because they involve a number range e.g. 200-500, 500-1000 etc... I am not sure what code I will need to make this work. Here is what ive done so far, Code:
<%@ Page MasterPageFile="~/MasterPage.Master" Language="vb" AutoEventWireup="false" CodeBehind="products.aspx.vb" Inherits="webproject.products" %> |
You really should move that inline SQL to at least the code behind; preferably to a stored proc... either way the correct syntax (without knowing your database structure that is) would be
Code:
SELECT * Code:
CREATE PROC usp_getProducts |
Change this:
Code:
<asp:DropDownList ID="ScreenDropDown" runat="server" Code:
<asp:DropDownList ID="ScreenDropDown" runat="server" *NOW* in your ASP.NET code you can do something like: Code:
Dim sizes As String() = Split( ScreenDropDown.SelectedValue, ":" )Pardon me if I goofed a bit in the VB syntax; been a long time since I used VB.NET. But the concept is right. |
And if it's not obvious: Do the same thing with price. And whether you use colon or dash between the range values doesn't matter. Just use the same character in the SPLIT( ) function call.
Just be sure that *ALL* of your values in the drop downs *ARE* ranges. In the PRICE dropdown, the first two shown are not. Fix them: Code:
<asp:ListItem Value="0-199.99">Under £200</asp:ListItem> |
I was gunna leave the finding out of split() to him :P
|
| All times are GMT +1. The time now is 08:36 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.