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
:)