user1056466
user1056466

Reputation: 667

Using More Than one query in a repeater

How to use more than one query in a repeater in asp.net. for e.g i have this repeater below and i want to use category names in it also i want to use a query which will return me the count of categories in a table how will i do that.

Repeater.

   asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" 

asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT [CategoryID], [CategoryName], [Description], [Picture] FROM [Categories]"></asp:SqlDataSource>

Upvotes: 0

Views: 64

Answers (1)

user3024816
user3024816

Reputation: 81

You can write a nested query as follows:

SELECT [CategoryID], [CategoryName], [Description], [Picture], (SELECT COUNT(*) FROM SOURCE_TABLE_NAME WHERE [CategoryID]=a.[CategoryID]) as [CATCOUNT] FROM [Categories] a

Where SOURCE_TABLE_NAME is the table name from where you want category count to be taken.

Upvotes: 1

Related Questions