Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2007, 05:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default rs.filter in asp.net - Please help

Hi to all,

I am a beginner in ASP.NET but I have been programming with classic ASP for more than 6 years.

What I am trying to do is a simple thing but can't figure it out on my own.

I want to create a select list drop down using the optgroup. A sample can be seen in this website http://www.aspen.com.mt/contactus.asp. The optgroup titles come from a database table and the sub lists will come from another table using the relationship on one of the fields. With classic asp is very simple by just using the rs.filter command but i can'figure it out in as.net. I tried various methods but for nothing.

Another thing is that I don't want to read the database every time but simply read it once and filter the data when neccessary. I want to use the same data more than once in the page so one trip to the database is always better. The rs.filter in classic asp was perfect for the job.

Please find below my code which obviously is not working fine:

Code:
<select id="testdrop">
<optgroup label="ivan">
<asp:SqlDataSource ID="airports_rs" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [airport_id],[airport_name],[country] FROM [Airports] WHERE ([country] LIKE @ivan)">
                                         <SelectParameters>
                                       <asp:Parameter DefaultValue="%" 
                                        Name="ivan" Type="String"/>
                                        </SelectParameters>
                                        </asp:SqlDataSource> 


                                        <asp:SqlDataSource ID="destinations_rs" runat="server" ConnectionString="<%$ ConnectionStrings:TRAVEXWEBConnectionString %>"
                                        SelectCommand="SELECT * FROM [Destinations]"></asp:SqlDataSource> 
                                        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="destinations_rs">
                                        <ItemTemplate>
                                        <optgroup label="<%#Eval("countryName")%>"></optgroup>



                                         <asp:Repeater ID="Repeater3" runat="server" DataSourceID="airports_rs">


                                        <ItemTemplate>   
                                       <% airports_rs.filter = "country LIKE 'malta'"%>
                                       <option value="ivan"><%#Eval("airport_name")%></option>

                                         </ItemTemplate>

                                        </asp:Repeater>  


                                        </ItemTemplate>
                                        </asp:Repeater>                                             
                                       </select>



I really appreciate if anyone can help me with some sample code how to achieve this with the most simple way as classic asp. A fully working example will be much appreciated as I am a beginner in asp.net.

Thanks in advance for your help.

Regards

:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Re: ASP DB/RS functions in ASP.NET spinout ASP.NET 2.0 Basics 7 May 29th, 2007 11:00 AM
Filter/Search row in asp.net Grid ghari ASP.NET 1.0 and 1.1 Professional 2 February 8th, 2006 12:04 AM
how to filter out unwanted selection in rs paging gilgalbiblewheel Classic ASP Databases 1 October 18th, 2004 07:21 AM
sum'ing columns after a filter (in rs) nlicata SQL Server ASP 2 August 21st, 2003 03:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.