数据绑定错误
错误:DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'N_tid'.
Line 73: <asp:TemplateField HeaderText="新闻类型">
Line 74: <EditItemTemplate>
Line 75: <asp:DropDownList ID="DropDownList1" runat="server"
Line 76: DataSourceID="AccessDataSource2" DataTextField="N_type"
Line 77: DataValueField="N_tid" SelectedValue='<%# Bind("N_tid") %>'>
是一个DetailsView编辑模式下的下拉框里面的内容,有问题的代码:
<asp:TemplateField HeaderText="新闻类型">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="AccessDataSource2" DataTextField="N_type"
DataValueField="N_tid" SelectedValue='<%# Bind("N_tid") %>'>
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource2" runat="server"
DataFile="~/hdu.mdb" SelectCommand="SELECT * FROM [ntype]">
</asp:AccessDataSource>
</EditItemTemplate>
但是用了同样语句的另一个模块却没有问题:
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="AccessDataSource3" DataTextField="N_type"
DataValueField="N_tid" SelectedValue='<%# Bind("N_tid") %>'>
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource3" runat="server"
DataFile="~/hdu.mdb" SelectCommand="SELECT * FROM [ntype]">
</asp:AccessDataSource>
</InsertItemTemplate>
------解决方案--------------------
那你看下你从数据库中取到了这个字段吗?