基本上我正在尝试填充一个部门表,并根据更改日期,为某个日期范围内的任何部门创建一个按钮。问题是,按钮创建但没有数据,
这是我到目前为止所拥有的 - onPageLoad 我绑定了所有工作并显示的数据源,直到我尝试 iTemDataBound
ASP.net
<asp:Repeater ID="DepartmentsList" runat="server" OnItemDataBound="DepartmentsList_ItemDataBound"/>
<HeaderTemplate>
<table id="grouptable" class="table table-bordered table-striped">
<thead>
<tr>
<th>Send</th>
<th>ID</th>
<th>Name</th>
<th>Last Modified</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<input type="checkbox" name="SendSelect[]" value="<%# Eval("Dept_ID") %>"</input></td>
<td><%# Eval("Dept_ID") %></td>
<td><a href="<%# Eval("gURL") %>"><%# Eval("DESC") %></a> </td>
<td><asp:Label ID="chg_date" runat="server" Text='<%# Eval("chg_date") %>'></asp:Label></td>
<td><a class="btn btn-info" href="<%# Eval("gURL") %>"><i class="icon-pencil icon-white"></i> Edit </a>  <asp:Button ID="bcastBtn" runat="server" Text="Send Now" CssClass="btn btn-danger" /> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
c# 代码
protected void DepartmentsList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
{
return;
}
else
{
Repeater bcastbuttonControl = (Repeater)item.FindControl("bcastBtn");
Repeater DepartmentsList = (Repeater)item.FindControl("chg_date");
//Coding for date validation to go here - at the minute just checking based on empty or null
if (String.IsNullOrEmpty(chg_date.Text))
{
bcastBtn.Visible = false;
}
else
{
bcastBtn.Visible = true;
}
}
}