I want to display a sort of list of people and some information linked to the day of the month in a choosen interval, like this:
Emp. | 01 | 02 | 03 |
Albert | aaa | bbb | ccc |
Dana | ccc | aaa | bbb |
John | bbb | ccc | aaa |
I set up a repeater like this:
<asp:TextBox ID="txtDataDa" Type="date" runat="server" ToolTip="Data Da" autocomplete="off"></asp:TextBox>
<asp:TextBox ID="txtDataA" Type="date" runat="server" ToolTip="Data A" autocomplete="off"></asp:TextBox>
<asp:Button ID="btnVai" runat="server" Text="Vai" OnClick="btnVai_Click"/>
<asp:Repeater ID="rptParent" runat="server">
<HeaderTemplate>
<table style="width: 100%;">
<tr>
<td>Dip</td>
</HeaderTemplate>
<ItemTemplate>
<td>
<asp:Label ID="lblGiorno" Text='<%# DataBinder.Eval(Container.DataItem, "data", "{0:dd}")%>' runat="server" />
</td>
<%--<asp:Repeater ID="rptChild" runat="server">
<ItemTemplate>
</ItemTemplate>
</asp:Repeater>--%>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
The Eval bit inside the label get a day from a datatable generated from a start and an end date set with 2 calendar control, I manage this with this bit in code behind:
Protected Sub btnVai_Click(sender As Object, e As EventArgs)
Dim data1, data2 As DateTime
data1 = Date.ParseExact(txtDataDa.Text, "yyyy-MM-dd", CultureInfo.CreateSpecificCulture("en-US")).Date
data2 = Date.ParseExact(txtDataA.Text, "yyyy-MM-dd", CultureInfo.CreateSpecificCulture("en-US")).Date
Dim dtGiorni As New DataTable
' Define columns
dtGiorni.Columns.Add("data", GetType(System.DateTime))
dtGiorni.Columns.Add("giorno", GetType(System.String))
' Add a row of data
Dim data As DateTime = data1.AddDays(-1)
Dim ita As Globalization.CultureInfo = New Globalization.CultureInfo("it-IT")
While data < data2
data = data.AddDays(1)
Dim nomeGiorno As String = ita.DateTimeFormat.GetDayName(data.DayOfWeek)
dtGiorni.Rows.Add(data, nomeGiorno.Substring(0, 1).ToUpper() + nomeGiorno.Substring(1))
End While
rptParent.DataSource = dtGiorni
rptParent.DataBind()
End Sub
If I select like 1th of march and 31th it shows correctly all the header colums with the day written inside. Now I want to create an undefined number of row based on the result of a mssql query to display the people in the first column and all the info in the right day. I think I have to use a nested repeater but I don't know how to set it up with the rest of the table. Any help, please? Thanks
EDIT: I don't mind to use another method instead of repeater, but please give some hint to start