[英]Silverlight - ListBox under an other ListBox - Databinding Question
[英]ListBox.DataBinding Method Question
有关ListBox.DataBinding方法的问题。 我正在加载带有DataRows数组对象的列表框,我想检查每个DataRow元素的列值是否为true / false。 如果该列的值为true,则修改当前listBox.ListItem对象的样式。 下面是一些示例代码:
System.Data.DataRow[] rows = Data.SchoolDetails.Select(filter);
lstBox.DataBinding += new EventHandler(lstBox_DataBinding);
lstBox.DataSource = rows;
lstBox.DataTExtField = "Value";
lstBox.DataValueField = "ValueCode";
lstBox.DataBind();
static void lstBox_DataBinding(object sender, EventArgs e)
{
ListBox l = (ListBox) sender;
}
您真的不能使用ListBox做到这一点。 也许您应该使用ListView,它支持每个项目的ItemDataBinding
事件。
最好的答案可能是您包含在上面的评论中的答案。
作为替代方案,我可以遍历DataRow数组并以此方式进行操作,并通过以下方式设置样式:lstBox.Items.Add(new ListItem(“”)。Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight,“ Bold “));。 感谢您的帮助。 –布兰登·迈克尔·亨特
那正是我要做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.