In a records repeater where database table has multiple votes for each choice in specific day, how can I bind / group records to be displayed for the last week days and each day votes appear separately or where to start to list the last 7 days before current day. can I do this only with stored procedure or there are code required? 

I'm using the following Repeater, Code and Stored Procedure which only returns a record per day.

Repeater
========

```
<asp:Repeater id="rpHistory" Runat="server">
   <ItemTemplate>
      <div class="row">
     <div class="col-md-3">
        <%# DataBinder.Eval(Container.DataItem, "WeekDay")%> <%# DataBinder.Eval(Container.DataItem, "Date")%>
     </div>
     <div class="col-md-3">
        <%# DataBinder.Eval(Container.DataItem, "VoteCount")%>
     </div>
      </div>
   </ItemTemplate>
</asp:Repeater>

```

Code
====

```
Dim drHistory As SqlClient.SqlDataReader
objDB.cmdGetOnlineChoiceHistory.Parameters("@iChoiceID").Value = Request("ChoiceID")
objDB.Conn.Open()
drHistory = objDB.cmdGetOnlineChoiceHistory.ExecuteReader(CommandBehavior.CloseConnection)
rpHistory.DataSource = drHistory
rpHistory.DataBind()
drHistory.Close()
objDB.Conn.Close()

```

Stored Procedure
================

```
@iChoiceID int
As
Begin
SELECT top 7 count(CV.Created) as VoteCount, CONVERT(VARCHAR(12), CV.Created, 101) as Date, DATENAME(weekday, CV.Created) as WeekDay from AVSBL_CategoryVotes CV group by CV.Created 
order by CV.Created desc
End

```

Image
=====

![Current and target outpot](https://i.stack.imgur.com/JP7lN.gif)

![Database table](https://i.stack.imgur.com/Sj7VW.gif)

UPDATE
======

For some reason the day format in "Created" Column and any convert in grouping didn't work. Since I needed the Created Column, I have added a column for DateDay with **DEFAULT (CONVERT([varchar],getdate(),(112)))** and used it instead.

```
@iChoiceID int
As
Begin
SELECT TOP 7 count(CV.Day) AS VoteCount, CONVERT(VARCHAR(12), 
CV.Day, 101) AS Date, 
DATENAME(weekday, CV.Day) AS WeekDay 
FROM AVSBL_CategoryVotes CV GROUP BY CV.Day 
ORDER BY CV.Day DESC
End

```

![enter image description here](https://i.stack.imgur.com/uVg2E.gif)