首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

“DataBinder.Eval:“System.Data.DataRowView”不包含名称为的属性”异常~请帮忙改改代码

2012-04-04 
“DataBinder.Eval:“System.Data.DataRowView”不包含名称为的属性”错误~~~!!!请帮忙改改代码前台:asp:data

“DataBinder.Eval:“System.Data.DataRowView”不包含名称为的属性”错误~~~!!!请帮忙改改代码
前台:
<asp:datagrid   id= "DataGrid1 "   runat= "server "   DataKeyField= "zsxm.id "   >
<Columns>
<asp:HyperLinkColumn   DataNavigateUrlField= "zsxm.id "   DataNavigateUrlFormatString= "xmxs.aspx?id={0} "   DataTextField= "mc "> </asp:HyperLinkColumn>
<asp:HyperLink   runat= "server "   Text= ' <%#   DataBinder.Eval(Container,   "DataItem.hyuser ")   %> '   NavigateUrl= ' <%#   string.Format( "hyxs.aspx?id={0} ",   DataBinder.Eval(Container,   "DataItem.hy.id "))     %> '   Target= "_blank "> </asp:HyperLink>
...
</asp:datagrid>

后台:
string   sql   =   "SELECT   zsxm.mc,   zsxm.id,   zsxm.sj,   hy.id,   hy.hyuser   FROM   zsxm   INNER   JOIN   hy   ON   zsxm.hyid   =   hy.id   ORDER   BY   zsxm.id   DESC ";    
DataView   zhuantiview   =   getdataview(sql,   "zhuanti1 ");  
DataGrid1.DataSource   =   zhuantiview;
DataGrid1.DataBind();  


[解决办法]
DataItem.id你两个id字段最好指定个别名。如 zsxml.id as id1
[解决办法]
前台:
<asp:datagrid id= "DataGrid1 " runat= "server " DataKeyField= "zsxmid " >
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField= "zsxmid " DataNavigateUrlFormatString= "xmxs.aspx?id={0} " DataTextField= "mc "> </asp:HyperLinkColumn>
<asp:HyperLink runat= "server " Text= ' <%# DataBinder.Eval(Container, "DataItem.hyuser ") %> ' NavigateUrl= ' <%# string.Format( "hyxs.aspx?id={0} ", DataBinder.Eval(Container, "DataItem.hy.id ")) %> ' Target= "_blank "> </asp:HyperLink>
...
</asp:datagrid>

后台:
string sql = "SELECT zsxm.mc, zsxm.id as zsxmid, zsxm.sj, hy.id as hyid, hy.hyuser FROM zsxm INNER JOIN hy ON zsxm.hyid = hy.id ORDER BY zsxm.id DESC ";
DataView zhuantiview = getdataview(sql, "zhuanti1 ");
DataGrid1.DataSource = zhuantiview;
DataGrid1.DataBind();

热点排行