我有 :
DataTable docTags;
List<IR_TagsName> tags = SomeClass.ShowTagsName(docIdentity);
foreach (DataRow dr in docTags.Rows)
{
foreach (IR_TagsName tag in tags)
{
if (dr["TagName"].ToString() == tag.TagName)
{
dr["TagValue"] = tag.RequestID;
}
}
}
TagsRepeater.DataSource = docTags;
TagsRepeater.DataBind();
中继器代码是:
<asp:Repeater ID="TagsRepeater" runat="server">
<ItemTemplate>
<div class="inputWrap">
<asp:Label ID="Label2" runat="server" AssociatedControlID="Tags"><%#DataBinder.Eval(Container.DataItem, "TagDescription")%>: </asp:Label>
<asp:HiddenField ID="TagName" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "TagName")%>' />
<asp:HiddenField ID="TagDataType" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "TagDataType")%>' />
<asp:TextBox ID="Tags" runat="server" Width="300" ReadOnly="true" Text='<%#DataBinder.Eval(Container.DataItem, "TagValue")%>' CssClass='<%# String.Format("Tag{0}", DataBinder.Eval(Container.DataItem, "TagName")) %>' />
<asp:Panel ID="ScriptPanel" runat="server" Visible='<%#(DataBinder.Eval(Container.DataItem, "tagdatatype").ToString() == "4" ? true : false)%>'>
<script type="text/jscript">
$(function () {
$(".Tag<%#DataBinder.Eval(Container.DataItem, "TagName")%>").datepicker({dateFormat: "dd.mm.yy"});
});
</script>
</asp:Panel>
</div>
</ItemTemplate>
</asp:Repeater>
这给了我例外: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'TagValue'.
我不确定这是循环 DataRow 和设置列表变量的正确方法...如果需要,我将发布更多详细信息