LinkButton btnCerFormsMon_Print = (LinkButton)sender;
Repeater Item = (Repeater)btnCerFormsMon_Print.NamingContainer;
Label referenceNo = (Label)Item.FindControl("rptrControlNo");
Label name = (Label)Item.FindControl("rptrRequester");
Label employeeNo = (Label)Item.FindControl("rptrEmployeeNo");
Label entryDate = (Label)Item.FindControl("rptrEntryDate");
Label document = (Label)Item.FindControl("rptrDocu");
Label Approver = (Label)Item.FindControl("rptrApprover");
Label requestStatus = (Label)Item.FindControl("rptrReqStatus");
Label rejectRemarks = (Label)Item.FindControl("rptrRejectRemarks");
hide_rptrControlNo.Text = referenceNo.Text;
hide_rptrStatus.Text = requestStatus.Text;
上面的代码会产生以下错误消息。
附加信息:无法转换类型&System; Web.UI.WebControls.RepeaterItem'输入' System.Web.UI.WebControls.Repeater'。
标记:
<asp:Repeater runat="server" ID="rptrCERFormsMonItems">
<ItemTemplate>
<tr>
<td class="col-xs-1 col-sm-1">
<asp:UpdatePanel runat="server" ID="UpdatePanelRepeater" UpdateMode="Conditional">
<Triggers></Triggers>
<ContentTemplate>
<asp:LinkButton runat="server" class="btn btn-sm btn-default" ID="btnCERFormsMon_Print" OnClick="btnCERFormsMon_Print_Click" CausesValidation="false" Text="<i class='fa fa-print' aria-hidden='true'></i> PRINT"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td class="col-xs-1 col-sm-1">
<asp:Label runat="server" ID="rptrControlNo" Text='<%#Eval("DI_REFERENCENO")%>' Style="text-transform: uppercase" />
</td>
<td class="col-xs-2 col-sm-2">
<asp:Label runat="server" ID="rptrRequester" Text='<%#Eval("DI_REQUESTEDBY")%>' Style="text-transform: uppercase" />
</td>
<td class="col-xs-2 col-sm-2">
<asp:Label runat="server" ID="rptrEmployeeNo" Text='<%#Eval("DI_EMPLOYEENO")%>' Style="text-transform: uppercase" />
</td>
<td class="col-xs-1 col-sm-1">
<asp:Label runat="server" ID="rptrEntryDate" Text='<%#Eval("DI_ENTRYDATE")%>' Style="text-transform: uppercase; float:right;" />
</td>
<td class="col-xs-1 col-sm-1">
<asp:Label runat="server" ID="rptrDocu" Text='<%#Eval("DI_DOCUMENTTOREQUEST")%>' Style="text-transform: uppercase" />
</td>
<td class="col-xs-2 col-sm-2">
<asp:Label runat="server" ID="rptrApprover" Text='<%#Eval("DI_APPROVER")%>' Style="text-transform: uppercase" />
</td>
<td class="col-xs-1 col-sm-1">
<asp:Label runat="server" ID="rptrReqStatus" Text='<%#Eval("DI_REQUESTSTATUS")%>' Style="text-transform: uppercase" />
</td>
<asp:Label runat="server" ID="rptrRejectRemarks" Text='<%#Eval("DI_REJECTREMARKS")%>' Visible="false" />
<asp:Label runat ="server" ID="rptrTime" Text='<%#Eval("DI_ENTRYTIME")%>' Visible="false" />
</tr>
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:0)
解决了它。不幸的是,repeater是一种用于显示的方法,当我将它绑定在我的转发器上时它无法找到数据表中的任何项目,因此我必须使用repeaterItem方法来转换转发器的obj。
RepeaterItem Item = (RepeaterItem)btnCerFormsMon_Print.NamingContainer;