我的网站我正在使用Repeater控件,它还包含checkboxlist控件。
现在我的问题是我已成功在转发器控件中绑定“参数类型”,但是当我绑定复选框值时,它不会出现在显示中
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<h4>
<%#Container.DataItem%></h4>
<asp:CheckBoxList ID="chkParList" runat="server" RepeatDirection="Horizontal"
DataTextField = >
</asp:CheckBoxList>
<br /><br />
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
以下* .cs文件是我的代码
IMonitoringDataInfo objMonitoringDataInfo = new ChannelFactory<IMonitoringDataInfo>("MonitoringDataInfo").CreateChannel();
Collection<ParameterDetailDTO> clParameterDetailDTO = objMonitoringDataInfo.GetAllParameters(idList, out errorCode);
var parameters = (from resx in clParameterDetailDTO
select resx.ParameterType).Distinct();
Repeater1.DataSource = parameters.ToList();
Repeater1.DataBind();
counter = Repeater1.Items.Count;
while (i < counter - 1)
{
foreach (var parType in parameters)
{
var items = from resx in clParameterDetailDTO
where resx.ParameterType.ToLower().Contains(parType.ToLower())
select new { resx.ParameterName, resx.ParameterID };
((CheckBoxList)(Repeater1.Items[i].FindControl("chkParList"))).DataSource = items;
((CheckBoxList)(Repeater1.Items[i].FindControl("chkParList"))).DataTextField = "ParameterName";
((CheckBoxList)(Repeater1.Items[i].FindControl("chkParList"))).DataValueField = "ParameterID";
((CheckBoxList)(Repeater1.Items[i].FindControl("chkParList"))).DataBind();
}
i++;
}
我使用LINQ作为数据源
请帮帮忙?
答案 0 :(得分:0)
将OnItemDataBound事件添加到Repeater:
<div id="root"></div>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script crossorigin src="https://unpkg.com/prop-types@15.6.2/prop-types.js"></script>
<script crossorigin src="https://unpkg.com/babel-standalone@6.26.0/babel.min.js"></script>
<script type="text/babel">
function SayHello(props) {
return (
<div>
Hello {props.firstName} {props.lastName}!
</div>
)
}
SayHello.propTypes = {
firstName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
}
ReactDOM.render(<SayHello />, document.getElementById('root'))
</script>
然后在后面的代码中执行以下操作:
<asp:Repeater ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" runat="server">
答案 1 :(得分:-1)
尝试将CheckBoxList绑定放在转发器的ItemDataBound事件中。
请参阅: