我正在尝试创建一个Employee Shift Scheduler。 目前,我正试图显示当前的变化。
如您所见,星期六有两班倒。我想在一个标题下显示这两个转变 - “2017年6月3日星期六”,而不是重复。
有人可以告诉我为了达到这个目的,我需要对代码做出哪些更改?
我在下面发布了我当前的代码:
HTML:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-lg-8 ">
<div class="col-lg-12">
<table class="table table-striped" aurelia-table="">
<thead>
<tr>
<th>test</th>
<th>test</th>
<th>test</th>
<th>test</th>
<th>test</th>
</tr>
</thead>
<tbody>
<tr class="">
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="form-group">
<select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
<option value="" selected=""></option>
<option value="-action"> Action</option>
</select>
</div>
</td>
<td>
<i class="fa fa-minus" aria-hidden="true" click.delegate=""></i>
</td>
</tr>
<tr class="">
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="form-group">
<select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
<option value="" selected=""></option>
<option value="-action"> Action</option>
</select>
</div>
</td>
<td>
<i class="fa fa-minus" aria-hidden="true" click.delegate=""></i>
</td>
</tr>
<tr class="">
<td>test</td>
<td>test</td>
<td>test</td>
<td>
<div class="form-group">
<select id="selectbasic" name="selectbasic" class="form-control col-lg-6 col-md-6 col-sm-6">
<option value="" selected=""></option>
<option value="-action"> Action</option>
</select>
</div>
</td>
<td>
<i class="fa fa-minus" aria-hidden="true" click.delegate=""></i>
</td>
</tr>
</tbody>
</table>
<!-- textarea -->
<div class="form-group">
<label class="col-md-12 control-label" for="textarea"></label>
<div class="row">
<div class="col-md-12">
<compose view="./-box.html"></compose>
</div>
</div>
</div>
</div>
</div>
C#:
<asp:Repeater ID="repSubscription" runat="server" OnItemDataBound="repSubscription_ItemDataBound">
<ItemTemplate>
<div class="col-lg-2">
<div class="panel panel-default">
<div class="panel-heading" style="background-color: #3A6EA5; color: white">
<h4 class="panel-title">
<%# Eval("Start_Time", "{0:dddd, dd MMMM yyyy}") %>
</h4>
</div>
<!--panel-heading-->
<div class="panel-body">
<asp:Repeater ID="repShift" runat="server">
<ItemTemplate>
<b><%# Eval("Job_Title") %></b>
</ItemTemplate>
</asp:Repeater>
</br>
<asp:Repeater ID="repEmp" runat="server">
<ItemTemplate>
<%# Eval("Employee_Name") %>
</ItemTemplate>
</asp:Repeater>
<br />
<asp:Repeater ID="repTimes" runat="server">
<ItemTemplate>
<%# Eval("Start_Time", "{00:HH:MM}") %> - <%# Eval("End_Time" , "{00:HH:MM}") %>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:0)
让我们从那个错误开始吧。更改以下内容时是否会出现相同的日期错误?如果没有,发生了什么?
protected void repFullSchedule_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
using (SqlConnection con = new SqlConnection(connectionString))
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater repCurrentShift = (Repeater)(e.Item.FindControl("repCurrentShifts"));
string Start_time = DataBinder.Eval(e.Item.DataItem, "Start_Time").ToString();
//DateTime my_Time = DateTime.ParseExact(Start_time, "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
SqlCommand cmd = new SqlCommand("Select Job_Type FROM Shift WHERE Start_Time=@my_Time", con);
cmd.Parameters.AddWithValue("@my_Time", Start_time);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
repCurrentShift.DataSource = dt;
repCurrentShift.DataBind();
}
}
}