I'm having a problem with a repeater:
1: I have a table with hours: 7:00 , 7:15, 7:30 , ... , and i use a repeater to read all of them and put days and buttons, here is the code:
<asp:Repeater ID="rptTable" runat="server" OnItemCommand="rptTable_ItemCommand">
<HeaderTemplate>
<table class="table table-hover">
<thead>
<tr>
<th>Horario</th>
<th>Lunes</th>
<th>Martes</th>
<th>Miércoles</th>
<th>Jueves</th>
<th>Viernes</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td><%# Eval("HorarioP") %></td>
<td>
<asp:LinkButton CssClass="btn btn-success" ID="btnlunes" runat="server" CommandName="turnolunes" CommandArgument='<%# Eval("HorarioP") %>'>Dar Turno</asp:LinkButton>
</td>
<td>
<asp:LinkButton CssClass="btn btn-success" ID="btnmartes" runat="server" CommandName="turnomartes" CommandArgument='<%# Eval("HorarioP") %>'>Dar Turno</asp:LinkButton>
</td>
<td>
<asp:LinkButton CssClass="btn btn-success" ID="btnmiercoles" runat="server" CommandName="turnomiercoles" CommandArgument='<%# Eval("HorarioP") %>'>Dar Turno</asp:LinkButton>
</td>
<td>
<asp:LinkButton CssClass="btn btn-success" ID="btnjueves" runat="server" CommandName="turnojueves" CommandArgument='<%# Eval("HorarioP") %>'>Dar Turno</asp:LinkButton>
</td>
<td>
<asp:LinkButton CssClass="btn btn-success" ID="btnviernes" runat="server" CommandName="turnoviernes" CommandArgument='<%# Eval("HorarioP") %>'>Dar Turno</asp:LinkButton>
</td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
This looks like this:
I need to filter these repeater by a dropdownlist (out of the repeater) to see different tables for differents medics (like a diary) and i need tu change the button to view turn or give turn (if have free scheduler or occupied scheduler).
I have two tables called medics and turns.
I need to do something like this, when i change the medic i need to see the free and occupied schedulers:
Where green buttons are free schedule and red buttons are occupied schedule.
The question is:
¿How i can analize in the repeater button by button in every day and hour if a medic have or dont have free schedule? I have a GetTurnsByMedic method; this returns all turns for a medic in a List.
Thanks to all!
I believe using ItemDataBound method could give you solution.
<asp:Repeater ID="rptTable" runat="server"
OnItemDataBound="rptTable_ItemDataBound">
protected void rptTable_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType.Equals(ListItemType.AlternatingItem) || e.Item.ItemType.Equals(ListItemType.Item))
{
//Call your method and do whatever you need to do here
//You can hide/show disable/enable your buttons
Button button = e.Item.FindControl("buttonID") as Button;
}
}