473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to filter content in a nested repeater

Hello everyone,

I am completly new to ASP.NET and I am attempting to design a web site
with it and VB.NET

I have been following an example from a book which as taken me to the
point where I want to branch out and add my own things to the website.

I have a MS SQL Server database that I am using to store the
information I need for the website content

In the book example they use a Datalist with a nested repeater, which
I have working fine.

However the book example lists all the products on one page.

I would like to know how I could filter the results that are viewed on
each page

I will be listing ebooks on my site and have five catagories that I
need to list them in.

Computing
Internet
Finance
Food
Software
the repeater code of have is:
<ItemTemplate>
<asp:Image ID="Image4" runat="server" AlternateText='<%#
Eval("ItemName") %>' ImageAlign="Left"
ImageUrl='<%# Eval("GraphicFileName", "images/{0}")
%>' Style="margin: 5px 10px 5px 0px" />
<asp:Label ID="Label2" runat="server" Font-Bold="True"
Font-Size="1.2em" Text='<%# Eval("MenuItemType") %>'></asp:Label>
-
<asp:Label ID="Label3" runat="server" Font-Bold="True"
Font-Size="1.2em" Text='<%# Eval("ItemName") %>'></asp:Label><br />
<br />

<asp:Repeater ID="Repeater1" runat="server" DataSource='<
%# CType(Container.DataItem, DataRowView).CreateChildView("MenuLink")
%>' OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<span style="color: Firebrick;">
<asp:LinkButton ID="OrderItem" runat="server"
ToolTip="Add item to order" style="text-decoration:none;"
CommandArgument='<%# Eval("ItemPrice")
%>'>
<asp:Image ID="Image1" runat="server"
ImageUrl="~/images/TrolleyIcon.gif"
AlternateText="Add item to order button" />
<%#Eval("ItemPrice", "£{0:F2}")%&nbsp;
</asp:LinkButton>
</span>
</ItemTemplate>
</asp:Repeater>
<br />
<br />
<asp:HyperLink ID="HyperLink1" runat="server" Font-
Bold="True" Font-Names="Corbel"
Font-Size="Large">Details</asp:HyperLink>
</ItemTemplate>
There is a field named menuItemType in my database and this lists the
catagories that I mentioned above.

So how would I modify this to just show items from the FOOD catagory
on the web page?

I hope I have explained myself OK

Thanks

Mar 1 '07 #1
1 2455
Add a dropdownlist at the top of the page - add items to the ddl that you
want to use as a filter, filling the VALUE of each item with the id of that
item in the database.
Then, starting with their sql query, add a where clause (however you'd like
it), based on the value
Select * from books WHERE category=@CategoryID

don't forget to either add a button to trigger this, or make your ddl's
autopostback property='True'

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"bob8000" <bo*****@hotmail.co.ukwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
Hello everyone,

I am completly new to ASP.NET and I am attempting to design a web site
with it and VB.NET

I have been following an example from a book which as taken me to the
point where I want to branch out and add my own things to the website.

I have a MS SQL Server database that I am using to store the
information I need for the website content

In the book example they use a Datalist with a nested repeater, which
I have working fine.

However the book example lists all the products on one page.

I would like to know how I could filter the results that are viewed on
each page

I will be listing ebooks on my site and have five catagories that I
need to list them in.

Computing
Internet
Finance
Food
Software
the repeater code of have is:
<ItemTemplate>
<asp:Image ID="Image4" runat="server" AlternateText='<%#
Eval("ItemName") %>' ImageAlign="Left"
ImageUrl='<%# Eval("GraphicFileName", "images/{0}")
%>' Style="margin: 5px 10px 5px 0px" />
<asp:Label ID="Label2" runat="server" Font-Bold="True"
Font-Size="1.2em" Text='<%# Eval("MenuItemType") %>'></asp:Label>
-
<asp:Label ID="Label3" runat="server" Font-Bold="True"
Font-Size="1.2em" Text='<%# Eval("ItemName") %>'></asp:Label><br />
<br />

<asp:Repeater ID="Repeater1" runat="server" DataSource='<
%# CType(Container.DataItem, DataRowView).CreateChildView("MenuLink")
%>' OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<span style="color: Firebrick;">
<asp:LinkButton ID="OrderItem" runat="server"
ToolTip="Add item to order" style="text-decoration:none;"
CommandArgument='<%# Eval("ItemPrice")
%>'>
<asp:Image ID="Image1" runat="server"
ImageUrl="~/images/TrolleyIcon.gif"
AlternateText="Add item to order button" />
<%#Eval("ItemPrice", "£{0:F2}")%&nbsp;
</asp:LinkButton>
</span>
</ItemTemplate>
</asp:Repeater>
<br />
<br />
<asp:HyperLink ID="HyperLink1" runat="server" Font-
Bold="True" Font-Names="Corbel"
Font-Size="Large">Details</asp:HyperLink>
</ItemTemplate>
There is a field named menuItemType in my database and this lists the
catagories that I mentioned above.

So how would I modify this to just show items from the FOOD catagory
on the web page?

I hope I have explained myself OK

Thanks
Mar 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tommy | last post by:
I have been working on getting nested repeaters to work for several days. When I add a repeater inside my item template i cannot see it in my code and can't set the datasource for it, etc, thus...
0
by: mark | last post by:
My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater to work just fine, as long as it's not...
1
by: Bojesphob | last post by:
Can someone help? I have a nested repeater in which I wish to format one of the bits of data in currency. I know that the code for the regular repeater (which works fine in parent) is...
0
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
1
by: Maziar Aflatoun | last post by:
Hi, I have tried setting up a nested repeater control and it works fine. But when I do 3 level nested repeater it fails. Does anyone know a site or have an example of a three level nestest...
3
by: Eirik Eldorsen | last post by:
Im trying to make a nested repeater with 3 levels. I've successfully created a nested repeater with 2 levels, but when adding the 3rd level I get an InvalidCastException. What am I doing wrong? ...
1
by: humbleFunGuy | last post by:
What does nested controls mean in .Net? Any help is appreciated. Thanks, fanzi
2
by: mark | last post by:
(not sure if this is the correct group) My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.